Why does setting XMLHttpRequest responseType before calling open throw?

后端 未结 2 1026
夕颜
夕颜 2020-12-30 01:40

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

相关标签:
2条回答
  • 2020-12-30 02:19

    It's a working draft, so it's normal if there are small differences or bugs in the implementations. I think Firefox still follows the behavior described in the draft of August 2011, where is specified that the exception is thrown if the state is not OPENED or HEADERS_RECEIVED.

    0 讨论(0)
  • 2020-12-30 02:19

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

    0 讨论(0)
提交回复
热议问题