Why does setting XMLHttpRequest responseType before calling open throw?(为什么在调用 open throw 之前设置 XMLHttpRequest responseType?)
问题描述
在控制台中运行 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么在调用 open throw 之前设置 XMLHttpRequest responseType?


基础教程推荐
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01