When I try to fetch a page asyncronously I get a status 0 and the response text is empty:
[code=php]var loaderImage = document.getElementById(“loader”);
loaderImage.style.display = “inline”;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4 && xmlhttp.status == 200) {
response = xmlhttp.responseText;
alert(response);
loaderImage.style.display = “none”;
return true;
}
}
url = “../cgi-bin/sendmessage.cgi?username=” + user_mobile + “&pass=” + mycosmosPsw + “&phone=” + mobile + “&mes=” + sms_text;
xmlhttp.open(“GET”,url,true);
xmlhttp.send(null);
but when the same request is made synchronously everything works..
[code=php]var loaderImage = document.getElementById(“loader”);
loaderImage.style.display = “inline”;
xmlhttp = new XMLHttpRequest();
url = “../cgi-bin/sendmessage.cgi?username=” + user_mobile + “&pass=” + mycosmosPsw + “&phone=” + mobile + “&mes=” + sms_text;
xmlhttp.open(“GET”,url,false);
xmlhttp.send(null);
loaderImage.style.display = “none”;
response = xmlhttp.responseText;
alert(response);
return true;
what shall I do to make the asynchronous code to work?
Should it be noted, the cgi file takes 2-4 seconds to load.