responseType property

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.
This topic has not yet been rated - Rate this topic

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

 

 

Send comments about this topic to Microsoft

Build date: 11/29/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

© 2013 Microsoft. All rights reserved.