PDA

View Full Version : Function won't work without an alert.


Chuunthor
06-13-2010, 01:17 PM
This functions works perfectly, as long as I have an alert() somewhere in it. If I remove the alert() call on line 27, it no longer functions. Any suggestions would be greatly appreciated!


function getResults(str)
{

if (str=="")
{
document.getElementById("txtHint").innerHTML="Null";
return;
}

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("searchResults").innerHTML=xmlhttp.responseText;
}
}
alert("");
xmlhttp.open("GET","get_data.php?q="+str,true);
xmlhttp.send();
}



Thanks!!