在IE11中设置xmlHttp响应类型为msxml-document会抛出无效状态错误
setting xmlHttp response type to msxml-document throws Invalid State Error in IE11
当我尝试将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的状态
相关文章:
- Jquery Datatables错误:无效的JSON基元:draw
- 错误:语法错误,无法识别的表达式:不支持的伪:无效/RectJS/Unit Testing
- JavaScript错误无效的限定符
- 如何使用JavaScript粘贴原始二进制文件而不出现“无效字符”错误
- 如何修复FF和IE中的Javascript无效日期错误
- 未捕获错误:Google Fusion表上的列索引无效
- 从ASP转换后出现无效ViewState错误.NET 1.1到ASP.净额3.5
- 错误:格式为整数的 javascript 键无效
- 在正则表达式中添加 (?i) 会导致 javascript 中出现错误“无效的正则表达式组”
- 使用JSON.parse时出现无效字符javascript错误
- 由 if / else 语句中的无效语法导致的语法错误
- 解析 JSON 时出现无效字符错误
- ReactJS - 元素类型无效错误
- Facebook JavaScript SDK 检查用户是否为粉丝(错误:指定的版本无效)
- Jqx图表给出错误错误:
属性高度=“-1”的负值无效 - IE 中的调用对象无效错误
- 更改无效(错误答案)的段落颜色和文本颜色
- 将包含内容和元数据的文件上传到谷歌文档会返回400无效/错误请求
- Foundation Abide-如果先前的输入无效,则在有效输入上触发无效错误
- 在解析JavaScript SDK时出现对象名称无效错误