Returns or sets the format the response will be returned in.
Property of apis/xhr/XMLHttpRequestapis/xhr/XMLHttpRequest
Syntaxvar result = element.responseType;
element.responseType = value;
Return Value
Returns an object of type
XMLHttpRequestResponseType, which is one of the following:
The following code demonstrates to how to use the requestType property of the XMLHttpRequest object to retrieve the results of the XHR request as an ArrayBuffer.
This can be used to load images, audio and other binary data with an XHR request. Once the response is received use the response property to access the ArrayBuffer.
function handler() {
if (xhr.readyState === 4 ) {
if (xhr.status === 200) {
console.log(xhr.response);
}
}
}
var xhr = new XMLHttpRequest();
xhr.responseType = "arraybuffer";
xhr.open("GET", "http://localhost/test.ogg", true);
xhr.onreadystatechange = handler;
xhr.send();
Related specifications
Microsoft Developer Network: Windows Internet Explorer API reference Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4