Export (0) Print
Expand All
3 out of 3 rated this helpful - Rate this topic

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

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.