Posted By

theshoveller on 02/17/11


Tagged

html5


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


Portable sendAsBinary for XHR


 / Published in: JavaScript
 

URL: http://javascript0.org/wiki/Portable_sendAsBinary

Use this to enhance non firefox browsers to support the sendAsBinary method.

  1. XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
  2. function byteValue(x) {
  3. return x.charCodeAt(0) & 0xff;
  4. }
  5. var ords = Array.prototype.map.call(datastr, byteValue);
  6. var ui8a = new Uint8Array(ords);
  7. this.send(ui8a.buffer);
  8. }

Report this snippet  

You need to login to post a comment.