MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

XMLHttpRequest.responseType

这篇翻译不完整。请帮忙从英语翻译这篇文章

草案
本页尚未完工.

XMLHttpRequest.responseType 属性是一个枚举值,返回响应的类型。 它还允许作者将响应类型更改为一个"arraybuffer", "blob", "document", "json", 或 "text" 。如果将一个空字符串设置为responseType的值,则将其假定为类型“text”。

Setting the value of responseType to "document" is ignored if done in a  Worker environment. When setting responseType to a particular value, the author should make sure that the server is actually sending a response compatible to that format. If the server returns data that is not compatible to the responseType that was set, the value of response will be null. Also, setting responseType for synchronous requests will throw an InvalidAccessError exception.

The values supported by responseType are the following:

Value Data type of response property
"" DOMString (this is the default value)
"arraybuffer" ArrayBuffer
"blob" Blob
"document" Document
"json" JavaScript object, parsed from a JSON string returned by the server
"text" DOMString
"moz-blob" Used by Firefox to allow retrieving partial Blob data from progress events. This lets your progress event handler start processing data while it's still being received.
"moz-chunked-text"

Similar to "text", but is streaming. This means that the value in response is only available during dispatch of the "progress" event and only contains the data received since the last "progress" event.

When response is accessed during a "progress" event it contains a string with the data. Otherwise it returns null.

This mode currently only works in Firefox.

"moz-chunked-arraybuffer"

Similar to "arraybuffer", but is streaming. This means that the value in response is only available during dispatch of the "progress" event and only contains the data received since the last "progress" event.

When response is accessed during a "progress" event it contains a string with the data. Otherwise it returns null.

This mode currently only works in Firefox.

"ms-stream" Indicates that the response is part of a streaming download. It is supported only for download requests. This mode is available only in Internet Explorer.

Specifications

Specification Status Comment
XMLHttpRequest Living Standard WHATWG living standard

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 31 12 12 18 7.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 4.4.1 55 50 ? ? ?

 

文档标签和贡献者

 此页面的贡献者: xgqfrms-GitHub
 最后编辑者: xgqfrms-GitHub,