NETWORK_ERR: XMLHttpRequest Exception 101
NETWORK_ERR: XMLHttpRequest Exception 101
我在Chrome中有一个AJAX问题,给出以下错误:
Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101
这是我的代码:
function IO(filename) {
if (window.XMLHttpRequest) { // Mozilla, Safari,...
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) { }
}
}
xmlhttp.open("GET", filename+"?random="+Math.floor(Math.random()*100000001), false);
xmlhttp.send();
if(xmlhttp.readyState==4)
return xmlhttp.responseXML;
}
解决方法是将async
参数设置为true
:
xmlhttp.open("GET", filename+"?random="+Math.floor(Math.random()*100000001), true);
除了在获取没有正确标头的跨站点URL时发生之外,在通过XHR (AJAX)获取本地文件时也会发生此错误。显然,Chrome在跨站点安全措施上过于热心,没有意识到一个文件URL应该被视为与另一个文件URL相同。这是许多本地应用的问题,尤其是Jasmine(一个JavaScript测试框架)。
Chrome版本16.0.912.63仍然发生。
我不知道任何解决办法。解决方法是使用Firefox或任何其他浏览器来运行从file: URLs获取的应用程序。
相关文章:
- Angular Hot毛巾 'blocks.exception' 和 'blocks.router' 不会在浏览器中显示
- RTCMultiConnection exception on connection.addStream()
- Ajax jquery exception
- Jasmine javaScript exception
- jQuery Ajax exception catcher
- TypeError (null reference exception) when using dom-construc
- $("*") with exception?
- 在 werkzeug-exception 上设置标头
- chrome.tabs.query status:loading -> exception?
- Running Java from Nashron JavaScript - Exception java.lang.C
- GWT, NoSuchElement exception
- Applet java.io.FilePermission exception
- PhoneGap iOS + DOM Exception 18
- Google Chrome NETWORL_ERR: XMLHttpRequest Exception 101
- Exception ClientScript.RegisterStartup on按钮单击
- 错误:未捕获的异常:[exception.."字符串包含一个..quot;
- Javascript: InvalidStateError:DOM Exception 11
- DOM Exception 18 getImageData
- jQuery mobile - DOM Exception 18
- 如何检查与nodejs的omegle集成中的错误(UNHANDLED EXCEPTION)