I'm doing some basic ajax requests for changing pages, example:
$(document.body).on('click', ".paging a", function (e) {
$.ajax({
type: "GET",
url: $this.attr('href'),
success: function (data) {
$("#main-content").html(data);
}
});
e.preventDefault();
return true;
});
The URL the ajax request calls to returns HTML, sometimes this HTML contains 30-40 <img>
images.
The problem I'm hitting is if you click two pages in quick succession there is a delay while the browser waits until it has loaded all the images in the HTML of the previous ajax request until it makes the next XHR call.
Is there a way to prioritise the XHR request ahead of the images? Basically if another page is clicked I want all current requests to stop and the XHR request to execute immediately. As far as I've seen this is occurring because browsers have a limit to how many asynchronous requests it'll make to one domain (i.e. 6 for chrome) and if I changed the images to use a sub-domain it would probably fix it, but I'm trying to find a way to do it without having to resort to sub-domains.