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

XMLHttpRequest.responseType

翻譯不完整。請協助 翻譯此英文文件

編撰中
本頁仍未完成

The XMLHttpRequest.responseType property is an enumerated value that returns the type of the response. It also lets the author change the response type to one "arraybuffer", "blob", "document", "json", or "text". If an empty string is set as the value of responseType, it is assumed as type "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(此為預設值)
"arraybuffer" ArrayBuffer
"blob" Blob
"document" Document
"json" JavaScript object, parsed from a JSON string returned by the server
"text" DOMString
"moz-blob"

FireFox 專用;允許在請求尚在進行中就開始接收已取得的 Blob 資料,所以能夠在 progress 事件處理器中就提早開始取得資料進行作業。

"moz-chunked-text"

類似於 "text",但為串流形式,所以只有在 "progress" 事件觸發時才可以取得資料,而且資料只包含到最後一次 "progress" 事件觸發時的狀態。

當 "progress" 事件下會回傳字串資料,其餘則會回傳 null

此模式目前為 FireFox 專用。

"moz-chunked-arraybuffer"

FireFox專用;類似於 "arraybuffer",但為串流形式,所以只有在 "progress" 事件觸發時才可以取得資料,而且資料只包含到最後一次 "progress" 事件觸發時的狀態。

在非 "progress" 事件下會回傳 null

此模式目前為 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.

規範

Specification Status Comment
XMLHttpRequest Living Standard WHATWG living standard

瀏覽器相容性

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 ? ? ?

文件標籤與貢獻者

 此頁面的貢獻者: jackblackevo
 最近更新: jackblackevo,