Created
May 2, 2013 23:00
-
-
Save RushOnline/5506113 to your computer and use it in GitHub Desktop.
To get right binary response we must use overrideMimeType method of XHR in beforeSend filter method of jQuery ajax call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: "POST", | |
url: href, | |
beforeSend: function (xhr) { | |
xhr.overrideMimeType("text/plain; charset=x-user-defined"); | |
}, | |
success: function(response) { | |
var binary = Array.prototype.map.call(response, function(c) { return c.charCodeAt(0) & 0xFF; }); | |
console.debug('ajax done: ', binary); | |
}, | |
error: function(result) { | |
console.debug('ajax failed: ', result); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment