I need the sendAsBinary()
function in javascript, but it seems that Chrome has removed it natively. On the Mozilla MDN (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), they provide a custom function which extends the XMLHttpRequest prototype:
if(!XMLHttpRequest.prototype.sendAsBinary) {
XMLHttpRequest.prototype.sendAsBinary = function(sData) {
console.log("calling sendAsBinary() method...");
var nBytes = sData.length, ui8Data = new Uint8Array(nBytes);
for(var nIdx = 0; nIdx < nBytes; nIdx++) {
ui8Data[nIdx] = sData.charCodeAt(nIdx) & 0xff;
}
this.send(ui8Data);
};
}
However, even though I implement the above, I am still getting:
Uncaught TypeError: Object #<XMLHttpRequest> has no method 'sendAsBinary'
In Chrome 30.0.1599.101
. I also never see my console.log()
message.