Jump to content

Archived

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

kid_drew

PHP Wait Screen

Recommended Posts

Does anyone know of a good way to implement a wait screen while some large query is being computed?  I can create a wait screen with a nice animated gif and all that, but I'm not sure how to do the timing.  I.e., how do you immediately go to another page after a form submit and wait at that screen until the data is ready then load the results page, or is that even possible in php?

Share this post


Link to post
Share on other sites
Hmmm, if you knew how long it would take everytime you could arrange it, but i doubt thats the circumstances.

Share this post


Link to post
Share on other sites
Don't quote me on this but I don't believe there is a PHP "pause" function.  At least not one that is easily done.

I KNOW this can be done with AJAX and I've even seen a few tutorials on the web.  I'm sure Google can help there.  If anything you can use the javascript settime() function (pretty sure that's the one) to give it (x) amount of time before refreshing the page.  Just my 2 cents!

Share this post


Link to post
Share on other sites
What about the fork() function?  Could you fork to run the query process in the background, run a do/while loop on your wait screen and redirect only when the forked process updates a session variable, or something similar?

I've never used fork, so I'm totally shooting in the dark.

Share this post


Link to post
Share on other sites
How long does a 'large query' take before it returns results ... and how long does it take to download whatever it is that tells the user to wait (as if they had any choice)?

Share this post


Link to post
Share on other sites
I'm not sure how long the longer queries are going to take.  I don't have any traffic yet.  =)

I think they have the potential to take 10-20 seconds.

Share this post


Link to post
Share on other sites
I know this isn't the "best" programming practice but a decent way to half-ass the solution would be to pop open a div when the user presses the submit button.  Basically the page will hang while the query is being performed so the <div> will stay open until the query is finished and the new page loads.

Maybe you could post to a new page that performs the query and throw a header() after the query is performed to redirect to the results.  I'm just throwing things out here = /

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.