Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

responseType property

Describes the data type of the response associated with the request.

This property is read/write.

Internet Explorer 10

Syntax

JavaScript
object.responseType = ptr
ptr = object.responseType

Property values

Type: DOMString

One of the following values:

ValueCondition
arraybuffer

The response is an array buffer.

blob

The response is binary data.

document

The response is a document.

ms-stream

The response is part of a streaming download. This value is supported only for download requests.

text

The response is text.

 

Examples

The following example uses the responseType property to request binary data from the server.


var xhr = new XMLHttpRequest();
xhr.open("GET", "download?name=" + name, true);
xhr.responseType = "blob";
xhr.onreadystatechange = function () {
  if (xhr.readyState == xhr.DONE) {
    var blob = xhr.reponse;
    var image = document.getElementById("my-image");
    image.addEventListener("load", function (evt) {
      URL.revokeObjectURL(evt.target.src);
    }
    image.src = URL.createObjectURL(blob);
  }
}
xhr.send();


See also

XMLHttpRequest

 

 

Show:
© 2014 Microsoft