为什么以下代码
Based on Mozilla example不起作用?使用Firefox 3.5.7&铬.
<!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>
请浏览器从本地磁盘(文件:/// C:/ Users / Maxim Veksler / Desktop / XMLHTTP.html)中拉出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中).