爲什麼下面的代碼Based on Mozilla example不起作用?試用Firefox 3.5.7 & Chrome。XMLHttpRequest從遠程主機獲取HTTP響應
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
</body>
<script>
var req = new XMLHttpRequest();
req.open('GET', 'http://www.mozilla.org/', false);
req.send();
if(req.status == 200) {
alert(req.responseText);
}
</script>
</html>
請瀏覽器正在從拉動本地磁盤的HTML(文件:/// C:/Users/Maxim%20Veksler/Desktop/XMLHTTP.html)
在Firefox它提供了以下錯誤:
uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/Maxim%20Veksler/Desktop/XMLHTTP.html :: <TOP_LEVEL> :: line 10" data: no]
我在做什麼錯?我想向遠程主機提交請求並提醒結果(稍後添加到div中)。
OK,它是如何與谷歌分析整合JavaScript代碼的工作? – 2010-01-15 15:14:52
@Maxim:你可能想看看這個帖子:**谷歌分析如何收集其數據?**:http://stackoverflow.com/questions/892049/how-does-google-analytics-collect-its -數據 – 2010-01-15 15:20:56