user1350345
user1350345

Reputation: 11

Auto refresh ajax display of php loop counter

I'm been around php for a few months, but am new to ajax. At this point, I've been able to use ajax to launch my php script and update my page results without reload and i've been able to auto refresh another script to run it more than once.

I have large recordsets that can take 8 - 10 - 12 minutes to process depending on what's being done. I'd like to be able to auto refresh an ajax "progress" display on my page that says "Processing record x of y" where x is the loop counter and y is the number of records in my recordset and both are php variables.

I've searched, but don't seem to find anything like this. Can anyone help point me in the right direction?

Thanks

Upvotes: 1

Views: 567

Answers (1)

aziz punjani
aziz punjani

Reputation: 25776

What you can do is while the first ajax is still in progress and php script runs update either a database record or a session variable with the progress. Then have periodic ajax requests ( other ajax requests apart from the main ajax request) that grab the progress from either the database record or session variable and send the progress back to the client, this progress can then be displayed. Keep doing this until the main ajax request has finished.

Upvotes: 2

Related Questions