'Uncaught Error: INVALID_STATE_ERR: DOM Exception 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?
Solution 1:[1]
The error comes from the order of execution:
xhttp.open("POST",xmlFile,true);
xhttp.setRequestHeader("Content-type","application/xhtml+xml");
xhttp.send(postData);
You must first open the connection and then set the request header otherwise you will get the error.
Solution 2:[2]
The XMLHttpRequest::Status is unavailable till the XMLHttpRequest::readyState has changed to 4 ie. a proper response has been acquired from the server and has now been populated in the Status variable.
Thus accessing the XMLHttpRequest::Status early can result in this error.
Solution: first verify readyState and only upon success — access 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!
}
}
Solution 3:[3]
Socket has not be configure/initialize/opened connection and send has been called
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Arun P Johny |
| Solution 2 | Ujjwal Singh |
| Solution 3 | Rahul Shakya |
