Hello, for some reason I never reach readystate "4" for when I make a call to the search function below. It doesn't seem to matter if I make the call one or more times, but when I change "true" to "false" in the httpObject.open method, I reach readysate 4. The "method" variable specifies the file name (e.g. "helloworld.php"). Any thoughts?
Quote:
function search(method){
var httpObject = getHTTPObject();
if (httpObject != null)
{
httpObject.open("GET", method, true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput(httpObject);
}
}
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else
{
alert("Your browser does not support AJAX.");
return null;
}
}
function setOutput(httpObject){
if(httpObject.readyState == 4)
{
alert("Hello world!");
}
}
|