JavaScriptによるファイルとバイナリデータの扱い
javascript
function test1(){
var xhr = new XMLHttpRequest();
xhr.open('GET', 'smp1.png', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
var arrayBuffer = this.response;
if (arrayBuffer) {
var i8ary = new Uint8Array(arrayBuffer);
console.log(i8ary);
}
};
xhr.send();
}
参考リンク
バイナリファイルをAjaxで取得する際に注意する点