jeudi 6 mars 2014

See anything wrong? XMLHttpRequest


Vote count:

0




This is my script code in the head element:



<script type="text/javascript">
function suggest1() {
var dam_text = document.getElementById("dam").value;

var xmlhttp;

if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("MicrosoftXMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("dam_return").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "dam_search.php?dam_text=" + dam_text, true);
xmlhttp.send();
}
</script>


This is my HTML below the above code:



<tr><td id="label">Dam:</td>
<td id="option">
<input type="text" name="dam" id="dam" value="<?php echo "$dam"; ?>" onkeyup="suggest1();">
<br />
<div id="dam_return">Please enter a search term.</div>
</td>
</tr>


Can anyone see anything that looks wrong? I can't figure it out.. been changing bits and bits for the past hour and can't figure it out!!


As for the PHP file I am 'GET'ing from, it is working correctly as I have tried to manually do the 'GET' function by going to 'dam_search.php?dam_text=TEST' (it returns true).



asked 30 secs ago






Aucun commentaire:

Enregistrer un commentaire