gpt4 book ai didi

javascript - 将 xmlHttp 响应类型设置为 msxml-document 会在 IE11 中引发无效状态错误

转载 作者:行者123 更新时间:2023-11-28 08:02:36 25 4
gpt4 key购买 nike

当我尝试将 XMLHTTPRequest 对象响应类型设置为“ms-xml”时,出现无效状态错误。有谁知道为什么?我附加了一些用于创建对象和设置 responseType 属性的示例代码。谢谢。

function getXHR() {
if (window.XMLHttpRequest) {
return (new window.XMLHttpRequest());
} else {
return (new ActiveXObject("Microsoft.XMLHTTP"));
}
}

function test() {
this._xmlhttp = getXHR();
try {
this._xmlhttp.open("POST", this.uri, this.async);
this._xmlhttp.setRequestHeader("Content-Type", "text/xml");
if (this.trace > 0) {
SoapDbg.out("SOAP URI", this.uri);
}
} catch (ex) {
throw (ex);
}

// form SOAPMethod header

try {
var method_header = this._action;
if (this.trace > 0) {
SoapDbg.out("SOAPMethodName", method_header);
}
this._xmlhttp.setRequestHeader("SOAPMethodName", method_header);
} catch (ex) {
throw (ex);
}

// form SOAPAction header

try {
var action_header = this._action;
if (this.trace > 0) {
SoapDbg.out("SOAPAction", action_header);
}
this._xmlhttp.setRequestHeader("SOAPAction", action_header);
} catch (ex) {
throw (ex);
}

if (this.trace > 0) {
SoapDbg.out("SOAP Envelope", this._envelope);
}

// make the request

try {
if (this.async) {
this._xmlhttp.onreadystatechange = this._onreadystatechange;
}
this._xmlhttp.send(this._envelope);
try {
this._xmlhttp.responseType = "msxml-document";
} catch (e) {
console.log("an error occured");
}
}
}

最佳答案

您能否尝试在 open() 之后设置responseType并重试...

this._xmlhttp.open("POST", this.uri, this.async);
try {
this._xmlhttp.responseType = 'msxml-document';
} catch (e) {}
...

这取决于您设置responseType时XmlHttpRequest的状态。

关于javascript - 将 xmlHttp 响应类型设置为 msxml-document 会在 IE11 中引发无效状态错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25211495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com