I'm trying to make "many" xhr request but it seems that every time it waits for the answer before making another request. It's like XHR makes a queue and always wait for the previous request to finish.
What can I do to run more simultaneous xhr request?
$('body').delegate('.download','click', function(evt){
evt.preventDefault(); // Not related
var xhr = new XMLHttpRequest();
xhr.open('GET', "proxy.php?" + this.href, true);
xhr.responseType = 'blob';
xhr.onload = function() {
if (this.status == 200) {
var blob = new Blob([this.response], {type:'audio/mp4'});
console.log(blob.size);
if(blob.size > 0){
$("<a>").attr({
download: name,
href: URL.createObjectURL(blob),
target: "_blank"
})[0].click();
}
}
};
xhr.send();
});
Not a lot.
Browsers enforce a limit on:
If you split your requests between more originals you might find your constraint raised from the first to the second of the above.
Try to find something about http2, there is some info. Http2 protocol have better supporting of parallel requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With