I have pretty simple AJAX and PHP code. When calling PHP via AJAX, it gets the response code as 0. The PHP code is running successfully, but I can not get the answer. What does this status mean “0” and how can I solve it?
function confirmUser(id)
{
xmlhttp=GetXmlHttpObject();
regid = id;
if (xmlhttp==null) {
alert ("Browser does not support HTTP Request");
return;
}
var url="confirm.php";
url=url+"?id="+id;
url=url+"&a=confirm";
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#txtHint" + regid).text("Awaiting confirmation");
} else {
alert (xmlhttp.status);
}
};
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
Well, this is the javascript that I used. Forgive me if I have to add something more than that. Also tell me what I missed. I appreciate your help.
GetXmlHttpObject Function:
function GetXmlHttpObject()
{
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
shyam source
share