XMLHttpRequest.status always returns 0
HTML
<a href="#" onclick="MyObj.startup()">click me</a>
js code
var MyObj =
{
startup : function()
{
var ajax = null;
ajax = new XMLHttpRequest();
ajax.open('GET', 'http://www.nasa.gov', true);
ajax.onreadystatechange = function(evt)
{
if(ajax.readyState == 4)
{
if (ajax.status == 200)
{
window.dump(":)\n");
}
else
{
window.dump(":(\n");
}
}
}
ajax.send(null);
}
}
ajax.statusalways returns 0, no matter what site it has, no matter what the actual return code is. I say actual because it ajax.statusTextreturns the correct value like OK or Redirect ...
ajax.readyState also returns the correct values and 4 at the end.
http://www.nasa.gov/? XMLHttpRequest - .
, -HTTP-, status 0. . https://developer.mozilla.org/En/Using_XMLHttpRequest#section_3.