I have a sql queries being executed via an ajax call, but I need to be able to check the progress of it and update a progress bar.
Here’s my simple ajax call (using JQuery):
var strResult = (($.ajax({url: URL,async: true}).responseText));
Any ideas how I listen for changes to update the bar?
PS. This question is nothing to do with SQL.
If you can break up the query into many components which can be executed separately, you can keep asking the server what is the progress.
For example, if you have to insert a lot of data into the db, instead of making one giant request to the db:
you can break it into many insert statements:
Then at any stage you can always count the number of rows which can give you the percentage.
For example, you know that you are suppose to insert 20000 rows. Then using an ajax call to the server which will do this:
which will return a number up to 20000 you can calculate the percentage.
Another solution is to use websockets but this will require a lot of config.