Portable sendAsBinary for XHR


/ Published in: JavaScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.