Jump to content

Load bar


gar onn

Recommended Posts

I have a script that performs multiple MYSQL SELECTION than analyses, and optimizes them in PHP and than put them back in the database,But it takes long to excute the script, so I would like a loading bar, so you can see the progress.Wat is the best way to do this?

Link to comment
Share on other sites

The best way IMHO is to launch a separate HTTP request with XMLHttpRequest (a.k.a. AJAX) for this long running task.As each query is executed, make an echo to signal JavaScript that the query in question is currently executing. JavaScript on the other hand should check the response every few miliseconds and update a progress bar of some kind (e.g. a div in another div, where the outer div's width represents the whole process, and the percentages of width on the inner represent the current progress) if there's new content (i.e. a new query has finished executing). Note that all of this should be happening at readyState 3, and on readyState 4, you can assume the whole thing is done, and take according actions (e.g. remove the progress bar).Don't forget to explicitly flush the output buffer at each echo.Important note: I haven't personally tried to do this, so I'm not sure if responseText will update as echoes come in. AFAIK, it should.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...