Progress bar reading sql records

Hello,
in a control form I have a php methods that opens a sc_select and reads a thousand records and performs operations on the individual values contained.
The process takes about a minute and I’d like to show a progress bar showing the percentage of completion.
I created a javascript method to increase the size of a text field with a green background and change the value of the field in the percentage of completion.
If I insert sc_ajax_javascript in the reading point of the next record by increasing the value I don’t see the box grow but the graphics are updated only at the end of the php function with the box at the maximum size and the text 100%.
Is there no way to show the effect of the bar growth function on each record pass?
Some idea?
Thanks

Try this approach
https://www.w3schools.com/howto/howto_js_progressbar.asp

yes I used the same code to create the progress bar.
But the problem is not the bar that works perfectly.
The problem is that inserting it in the function of reading sql of the records, the “display” of the growth of the bar is not seen until the end of the function when it is 100% complete.
I need that every time I call the javascript function that change the width of the bar, the view is updated and after the code it continues with the reading of the record.
I do not know if I was clear.
Thank you

This is an issue with executing code on the server vs. executing locally through the browser. Javascript executes on the browser, but the SQL is going to complete its transaction on the server before returning back to the client browser with the progress completed.
Best you could probably do is put up some kind of ‘waiting’ or spinning wheel, etc that could be there until the process returns.