11

I am getting the below error.

Uncaught Error: INVALID_STATE_ERR: DOM Exception 11

Here is the code where I am getting Error RUN TIME.

xhttp.setRequestHeader("Content-type","application/xhtml+xml");<br>
xhttp.open("POST",xmlFile,true);<br>
xhttp.send(postData);

I tried with false in the third parameter of xhttp.open.
Can anyone tell me what's causing this?

4

3 回答 3

22

错误来自执行顺序:

xhttp.open("POST",xmlFile,true);
xhttp.setRequestHeader("Content-type","application/xhtml+xml");
xhttp.send(postData);

您必须首先打开连接,然后设置请求标头,否则您将收到错误消息。

于 2012-08-22T11:53:19.763 回答
1

在更改为ieXMLHttpRequest::Status之前不可用。已从服务器获取正确的响应,现在已填充到变量中。XMLHttpRequest::readyState4Status

因此,提前访问 XMLHttpRequest::Status 可能会导致此错误。

解决方案:首先验证readyState并且只有在成功时才能访问Status

if (xmlhttp.readyState==4)
{
    switch (xmlhttp.status)
    {
    case 200: // Do the Do
        break;
    case 404: // Error: 404 - Resource not found!
        break;
    default:  // Error: Unknown!
    }
}
于 2013-01-05T13:03:06.650 回答
0

套接字尚未配置/初始化/打开连接并且已调用发送

于 2022-02-02T09:08:48.790 回答