responseType
ResponseType is a property of the XMLHttpRequest interface used in web browsers to control how a response is delivered to client code. It determines the data type into which the server’s response is converted, allowing efficient handling of text, binary data, or documents.
- "" (empty string): the default, the response is provided as text via responseText.
- "text": the response is returned as text, similar to the default.
- "arraybuffer": the response is an ArrayBuffer suitable for binary data processing.
- "blob": the response is a Blob object.
- "document": the response is parsed as an HTML or XML Document.
- "json": the response is parsed as JSON and exposed as an object via response.
Some browsers have non-standard values such as "moz-chunked-arraybuffer" for streaming binary data and "ms-stream" for IE/Edge;
Usage notes: Set xhr.responseType before calling xhr.send(). When the request completes, xhr.response contains the data in
Comparison: Fetch API provides similar capabilities but without a responseType property; instead, you invoke response.text(), response.json(),