【发布时间】:2016-08-13 12:32:45
【问题描述】:
在 IE9 中执行 XDomainRequest 时,我不断收到“拒绝访问”。
我已经尝试了很多不同的解决方案,目前没有任何效果。
注意:脚本在 HTTP 上,而它正在请求的服务器是 HTTPS
下面是我的代码:
let xhr = new XMLHttpRequest();
if ('withCredentials' in xhr){
xhr.open('POST', XHR_URL, true);
} else if (typeof XDomainRequest != 'undefined'){
xhr = new XDomainRequest();
xhr.open('POST', XHR_URL);
} else {
xhr = null;
return;
}
xhr.setRequestHeader('Content-type', 'text/plain');
xhr.onreadystatechange = () => {
if(xhr.readyState == 4 && xhr.status == 200) {
// do something
}
}
xhr.onprogress = function () { };
xhr.ontimeout = function () { };
setTimeout(function () {
xhr.send(params);
}, 0);
需要帮助,谢谢!
【问题讨论】:
标签: ajax xmlhttprequest internet-explorer-9 xdomainrequest