Irfan
Irfan

Reputation: 1768

Simple XmlHttpRequest AJAX not outputting desired status code

My first and very simple AJAX request not outputting "status 200 OK".. and instead outputs "0" .. What's wrong?

function doit(){
var httpxml = new XMLHttpRequest();

httpxml.onreadystatechange = function(){
if(httpxml.readyState == 4) {
    alert(httpxml.status);
        }
    }
httpxml.open("GET", "http://localhost/test/ROUGH/TEST.php", true);
httpxml.send(null);
}
doit();

Upvotes: 0

Views: 234

Answers (1)

Irfan
Irfan

Reputation: 1768

The main reason for status 0 is that it has run from the disk and not through a webserver.

Upvotes: 1

Related Questions