How to get real-time results using jquery?

I make different queries with PHP and jQuery, and get results with .ajax() when all queries return their values.

What I want to do is get these values ​​as soon as they are ready. Now the user needs to wait until all requests are completed, but the first request returns its value 30 seconds before the second, so I do not want the user to wait to see all the results at once, I want them to see the result only the result returns.

How can i do this?

0
source share
1 answer

If you expect multiple database queries to return, you might consider splitting your web services into multiple AJAX calls. In other words, make 2 AJAX requests, one for the first request and the second for the second request (which gets its value 30 seconds after the first). That way, you can return the first request to the page and display it - or something else that needs to be done - waiting for any additional AJAX calls.

Of course, you can extend this technique to additional AJAX requests as needed.

+1
source

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


All Articles