I have an ajax event “onUpdateCars” which basically loop through cars model and update the record. There are 5k cars which take around 5 - 10 minutes. Besides showing the ajax loading gif or similar in css, it would be great to show the progress in a progress bar.
My question is that how can i accomplish this. Similar funitionality like installing a plugin and you can see the progress bar.
Thanks alot.
P.S: this is for educational purpose and nothing to do with real cars
@daft will ot be possible to put your idea how can i manage this? Thanks in advance
@artistro08 my question is to update the progress bar when the loop is still running. E.g after the 10th loop the progress bar should be at 10% (assuming total loops are 100).
In that case, wouldn’t it be easy to run some JavaScript code via an ajax function to update the progress bar?
You would first need to get the loop length, and store that variable. Then during the loop you’ll need someone math to determine the percentage of the progress based on the loop length
Once you’re done, you can adjust the width of the progress bar via JavaScript.
This way would be choppy, but would work. Id take a look at how October does it in the source code as well to get an idea of a smoother way.
This is an illusion approach to overcome the inability for PHP to report on its processing status. This is something only websockets or native apps can do by using multithreading. PHP is single threaded for the most part.