Receiving AJAX HTTP Response Code as 0

Posted by shyam on Stack Overflow See other posts from Stack Overflow or by shyam
Published on 2010-04-23T10:04:49Z Indexed on 2010/04/23 10:43 UTC
Read the original article Hit count: 191

Filed under:
|

I have a pretty simple AJAX and PHP code. While calling the PHP through the AJAX it receives the response code as 0. The PHP code is successfully run, but I can't get the response. What does this status '0' denote and how can I solve this?

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); //this shows '0'
        }
    };
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

Well, this is the javascript I used. Pardon me if I should've added anything more than this. Also tell me what I missed. I appreciate your help

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about httpresponse