I need an array containing blobs, so my code is:
for (var i = 0; i < total; i++) {
var xhr = createXHR();
xhr.open('GET', 'img/tiles/' + zeroFill(i, 4) + '.png', true);
xhr.responseType = 'blob';
xhr.onload = function() {
arr[i] = new Blob([this.response], {type: 'image/png'});
// console.log(arr[i]);
};
xhr.send();
}
When I output the i position of the arr, the console shows the blob correctly (at least, it says its size). If I try to display previous positions, I get undefined.
If I look the arr once all XHR requests have been completed, the console shows a weird array with every position undefined and the last with an uncompleted blob.