0
<html>
<body>
<SCRIPT type="text/javascript">
var xmlHttp = new XMLHttpRequest();
var async = true;
xmlHttp.open("GET", "http://www.google.com", async);
if(async)
{
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
if (xmlHttp.status==200) alert("It works!")
else if (xmlHttp.status==0) alert("Arggggg!")
else alert("Status is "+xmlHttp.status)
}
}
}
xmlHttp.send();
</script>
</body>
</html>
我只是好奇XMLHttpRequest来查看它并正常工作,但我无法获得状态为非零。这些例子看起来很简单,但它不起作用。我已经尝试了大约4个例子。有没有搞错 ?XMLHttpRequest简单的HTTP GET不工作?
我想要做的就是读取网页并以纯文本格式查看HTML。
就是这样。这是一个用你的代码返回一个404的例子:http://jsfiddle.net/dFyjt/ – Andir 2010-07-14 13:48:31