The XMLHttpRequest.responseType
property is an enumerated value that returns the type of response. It also lets the author change the response type. If an empty string is set as the value of responseType, the default value text
will be used.
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" | JSON |
"text" | DOMString |
"moz-chunked-arraybuffer"
| Similar to When 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. |
Specification | Status | Comment |
---|---|---|
XMLHttpRequest | Living Standard | WHATWG living standard |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 31 | (Yes) | 12[1] | 10 | 18 | 7.1 |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | 4.0.3 [2] | 55 | (Yes) | 50[1] | 10 | ? | ? |
[1] The proprietary moz-blob
and moz-chunked-text
values were removed completely in Firefox 58.
[2] Only text
and arraybuffer
supported.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType