无法使用XMLHttpRequest获取数据(状态0和responseText为空):
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();
它警告"状态0".
与localhost请求相同的情况(cd_catalog.xml保存为本地文件)
xmlhttp.open("GET","http://localhost/cd_catalog.xml", true);
但是使用localhost IP请求
xmlhttp.open("GET","http://127.0.0.1/cd_catalog.xml", true);
并使用本地文件请求
xmlhttp.open("GET","cd_catalog.xml", true);
一切都好(状态200)
什么可以导致问题(状态= 0)与在线请求?
PS:Live HTTP Headers显示在所有4种情况下一切正常:
HTTP/1.1 200 OK Content-Length: 4742
PS2:VMWare上的Apache本地Web服务器(主机OS Win7,Guest OS Ubuntu,网络适配器 - NAT).浏览器 - Firefox.