【发布时间】:2014-07-09 09:01:58
【问题描述】:
我尝试在 http://localhost:8080/ 上执行简单的 AJAX 请求,但在使用 IE 11 时立即收到错误消息。我认为 IE 甚至没有尝试发送任何内容。
有人遇到过这个问题吗?
这是一个 fiddle 显示此行为,
html:
<button id='btn1'>launch</button>
加载:
var xhr,btn=document.getElementById('btn1');
btn.onclick=onButton;
var onReadyState=function(){
console.log('ready state:'+_xhr.readyState);
if(xhr.readyState===4){
console.log('status:'+_xhr.status);
}
}
function onButton(){
xhr=new window.XMLHttpRequest();
xhr.onreadystatechange=onReadyState;
xhr.open('POST','http://localhost:8080/ScanAPI/v1/client');
xhr.send();
}
在尝试之前,您需要启动 IE F12 开发人员工具,您会看到 IE 捕获异常。
对此的任何帮助将不胜感激。
谢谢!
【问题讨论】:
标签: javascript exception xmlhttprequest cors internet-explorer-11