XMLHttpRequestResponseType

XMLHttpRequestResponseType type is an enumerated set of strings which are used to specify the type of data contained in the response of an XMLHttpRequest . These values are used when getting or setting the responseType on the request.

Values

""
An empty responseType string is treated the same as "text" , the default type.
arraybuffer
response is a JavaScript ArrayBuffer containing binary data.
blob
response Blob object containing the binary data.
document
response is an HTML Document or XML XMLDocument , as appropriate based on the MIME type of the received data. See HTML in XMLHttpRequest to learn more about using XHR to fetch HTML content.
json
response is a JavaScript object created by parsing the contents of received data as JSON .
text
response is a text in a DOMString 对象。
ms-stream
response is part of a streaming download; this response type is only allowed for download requests, and is only supported by Internet Explorer.

Deprecated values

moz-chunked-arraybuffer

A Firefox-only value which instructs XMLHttpRequest to deliver ArrayBuffer objects containing chunks of the incoming data. Accessing response during a progress event returns the data received so far. Outside the progress event handler, the value of response is always null . You shouldn't use this non-standard (and, as of Firefox 68, entirely removed) API; instead, consider using the Fetch API with readable streams , which offers a standard alternative to accessing the response in a streaming fashion.

规范

规范 状态 Comment
XMLHttpRequest 未知 Live standard, latest version

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
responseType Chrome 31 Edge 12 Firefox 6 IE 10 Opera 18 Safari 7 WebView Android 55 Chrome Android 55 Firefox Android 50 Opera Android 42 Safari iOS 7 Samsung Internet Android 6.0
arraybuffer Chrome 31 Edge 12 Firefox 6 IE 10 Opera 18 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 50 Opera Android Yes Safari iOS ? Samsung Internet Android Yes
blob Chrome 31 Edge 12 Firefox 6 IE 10 Opera 18 Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 50 Opera Android Yes Safari iOS ? Samsung Internet Android Yes
document Chrome 31 Edge 12 Firefox 11 IE 10 Opera No Safari 7 WebView Android Yes Chrome Android Yes Firefox Android 50 Opera Android Yes Safari iOS ? Samsung Internet Android Yes
json Chrome 31 Edge 79 Firefox 10 IE No Opera 18 Safari 7 WebView Android Yes Chrome Android Yes Firefox Android 50 Opera Android ? Safari iOS ? Samsung Internet Android Yes
moz-blob
弃用 非标
Chrome No Edge No Firefox 12 — 58 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No
moz-chunked-arraybuffer
弃用 非标
Chrome No Edge No Firefox 14 — 68 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 50 — 68 Opera Android No Safari iOS No Samsung Internet Android No

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。

另请参阅