Cannot get data with XMLHttpRequest (status 0 and responseText is empty):
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","http://www.w3schools.com/XML/cd_catalog.xml", true);
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
alert("status " + xmlhttp.status);
}
xmlhttp.send();
It alerts "status 0".
The same situation with the localhost request (cd_catalog.xml is saved as a local file)
xmlhttp.open("GET","http://localhost/cd_catalog.xml", true);
But with the localhost IP request
xmlhttp.open("GET","http://127.0.0.1/cd_catalog.xml", true);
and with the local file request
xmlhttp.open("GET","cd_catalog.xml", true);
everything is OK (status 200)
What can cause the problem (status=0) with the online request?
PS: Live HTTP Headers shows that everything is OK in all 4 cases:
HTTP/1.1 200 OK
Content-Length: 4742
PS2: Apache local web server on VMWare (host OS Win7, Guest OS Ubuntu, Network adapter – NAT). Browser – Firefox.
No comments:
Post a Comment