Uncaught Error: INVALID_STATE_ERR: DOM Exception 11

Anildhara picture Anildhara · Aug 22, 2012 · Viewed 15.4k times · Source

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?

Answer

Anonymous picture Anonymous · Aug 22, 2012

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.