为什么在调用open throw之前设置XMLHttpRequest responseType? [英] Why does setting XMLHttpRequest responseType before calling open throw?

查看:163
本文介绍了为什么在调用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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆