DOM Exception in XMLHttpRequest

Alec Jacobson

April 18, 2013

weblog/

I was getting this error when trying to set up an XMLHttpRequest using javascript:
INVALID_STATE_ERR: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable
The problem was that I was calling req.setRequestHeader(...) before calling req.open(...). Reversing the order fixed the problem.