Why does setting XMLHttpRequest responseType before calling open throw?

Lex R picture Lex R · Dec 24, 2013 · Viewed 10.8k times · Source

Running new XMLHttpRequest().responseType = "json" in the console throws an "InvalidStateError" exception in Firefox 26 and IE11 but not in Chrome 31.

Why?

The Spec states that setting responseType

throws an "InvalidStateError" exception if the state is LOADING or DONE.

but in this case the state is UNSENT.

What's going on?

Answer

Sebas picture Sebas · Jan 7, 2016

Note that setting responseType after I call open on the xhr object solved my problem (using IE11)