MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Compare Revisions

Using XMLHttpRequest

Change Revisions

Revision 2289:

Revision 2289 by emk on

Revision 2290:

Revision 2290 by emk on

Title:
Using XMLHttpRequest
Using XMLHttpRequest
Slug:
DOM/XMLHttpRequest/Using_XMLHttpRequest
DOM/XMLHttpRequest/Using_XMLHttpRequest
Tags:
AJAX, DOM, XML, NeedsTechnicalReview, NeedsMarkupWork, XMLHttpRequest, NeedsCompatTable, MakeBrowserAgnostic, NeedsCleanup, JXON
AJAX, DOM, XML, NeedsTechnicalReview, NeedsMarkupWork, XMLHttpRequest, NeedsCompatTable, MakeBrowserAgnostic, NeedsCleanup, JXON
Content:

Revision 2289
Revision 2290
tt286    <p>
287      {{ gecko_minversion_header("6") }}
288    </p>
289    <p>
290      Gecko 6 {{ geckoRelease("6") }} adds <code>r</code><code>es
 >ponseType</code> and <code>response</code> properties to the XMLH
 >ttpRequest object on behalf of the <code>mozResponseArrayBuffer</
 >code> property.
291    </p>
292    <pre class="deki-transform">
293var xhr = new XMLHttpRequest();
294xhr.open("GET", "binary_file", false);
295xhr.responseType = "arraybuffer";
296xhr.send(null);
297 
298buffer = xhr.response;
299if (buffer) {
300  var byteArray = new Uint8Array(buffer);
301  for (var i=0; i&lt;byteArray.byteLength; i++) {
302    // do something with each byte in the array
303  }
304}
305</pre>
306    <p>
307      This example reads a binary file and interprets it as 8-bit
 > unsigned integers.
308    </p>

Back to History