response
Summary
Returns the response entity body, which is the fragment of the entity body of the response received so far (if LOADING) or the complete entity body of the response (if DONE).
Property of apis/xhr/XMLHttpRequestapis/xhr/XMLHttpRequest
Syntax
Note: This property is read-only.
var result = element.response;
Return Value
Returns an object of type anyany
Examples
This example reads an image as a binary file and creates an 8-bit unsigned integer array from the raw bytes.
var oReq = new XMLHttpRequest();
oReq.open("GET", "/myfile.png", true);
oReq.responseType = "arraybuffer";
oReq.onload = function (oEvent) {
var arrayBuffer = oReq.response; // Note: not oReq.responseText
if (arrayBuffer) {
var byteArray = new Uint8Array(arrayBuffer);
for (var i = 0; i < byteArray.byteLength; i++) {
// do something with each byte in the array
}
}
};
oReq.send(null);
Related specifications
- W3C XMLHttpRequest Specification
- W3C Working Draft
Attributions
Mozilla Developer Network : Article
Microsoft Developer Network: Windows Internet Explorer API reference Article