JQuery AJAX Queue Priority

I have a large table of "extra" data that is populated from a large number of ajax requests when the page loads. These queries may take up to 1 minute. While this data is loading, the user can perform actions on the page that trigger additional ajax requests. The problem I am facing is that the user action causing the additional ajax request does not end until all other ajax requests in the queue have been processed. This is due to the use of all browser connections of the same domain and jQuery ajax queue.

Unfortunately, changing subdomains is not an option and does not create a synchronous queue so as not to use all the same connections to the domain.

What I would like is an option to “prioritize” requests by first placing a user request.

Is there an easy way to accomplish this using jQuery ajax queue?

EDIT:

If there is no way to manage the request queue (as it starts to display), can the $ .ajax beforeSend callback function be used to “defer” the requests requested in the queue?

+4
source share
1 answer

As soon as the request is sent, it contacts the server to process it. Since it is asynchronous, you cannot control when the response will be received and in what order. Also, the server does not even “know” that other requests are expected for the same session ... Perhaps you can change this, but this will require a lot of work on how the web server manages the requests.

The only thing you can really do is to prevent user interaction before loading all the data.

+2
source

Source: https://habr.com/ru/post/1393796/


All Articles