在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);需要帮助,谢谢!
发布于 2016-07-12 16:35:43
如果你从IE9开始,那么你的xhr会调用新的XDomainRequest(也称为xdr)。但是,xdr没有'setRequestHeader‘。
https://stackoverflow.com/questions/36750423
复制相似问题