問題描述
在控制臺中運行 new XMLHttpRequest().responseType = "json"
會在 Firefox 26 和 IE11 中引發InvalidStateError"異常,但在 Chrome 31 中不會.
Running new XMLHttpRequest().responseType = "json"
in the console throws an "InvalidStateError" exception in Firefox 26 and IE11 but not in Chrome 31.
為什么?
規范聲明設置 responseType
如果狀態為 LOADING 或 DONE,則拋出InvalidStateError"異常.
throws an "InvalidStateError" exception if the state is LOADING or DONE.
但在這種情況下,狀態是 UNSENT.
but in this case the state is UNSENT.
發生了什么事?
推薦答案
這是一個工作草案,所以如果在實現中存在小的差異或錯誤是正常的.我認為 Firefox 仍然遵循 2011 年 8 月草案 中描述的行為,其中指定拋出異常如果狀態不是 OPENED
或 HEADERS_RECEIVED
.
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
.
這篇關于為什么在調用 open throw 之前設置 XMLHttpRequest responseType?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!