A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/apis/xhr/XMLHttpRequest/responseType below:

responseType ยท WebPlatform Docs

responseType Summary

Returns or sets the format the response will be returned in.

Property of apis/xhr/XMLHttpRequestapis/xhr/XMLHttpRequest

Syntax
var result = element.responseType;
element.responseType = value;
Return Value

Returns an object of type

XMLHttpRequestResponseType, which is one of the following:

Examples

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
W3C XMLHttpRequest Specification
W3C Working Draft
Attributions

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