IE9 CORS XDomainRequest访问被拒绝



在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);

需要帮助,谢谢!

如果从IE9开始,则xhr调用新的XDomainRequest(也称为xdr)。但是,xdr没有"setRequestHeader"。

最新更新