How to display a "wait" page while php busy ?

fomalhaut

Member
Messages
107
Reaction score
0
Points
16
Hello

While php works on an image (upload with transformation: imagecreatetruecolor, imagecreatefromjpeg, imagecopyresample, imagejpeg...) I would like to display a page that makes the client understand it's working, and there is some seconds of wait. And naturely, I want this page disappears when the imagedestroy is ended.

How can I do that ? I've tried with javascript DOM to make a layer visible or not, but that is made only when all is finished, not while the php code is running !

Thank for your answers.
 

fomalhaut

Member
Messages
107
Reaction score
0
Points
16
Thank you two for the links. But in fact, I was wrong, and probably I do not explain well. I wanted only show one of my page while server works. I had an error in my script (the "id" in the object tag html was not which I used in the Javascript !) I've find it, it works well now.

Thanks again for your answers.
 

learning_brain

New Member
Messages
206
Reaction score
1
Points
0
There is a simpler php solution that I use to see if the page is processing as it should.

flush() and ob_flush().

Each time this function is called, it forces the previous content to output to display.

If you enter these after each echo or <img>, they will appear on screen as soon as they have been processed and you don't have to wait for the whole page to load.

Progress meters can work on a similar principal.

If you go to the crawler page on my site, you'll see it working.

www.qualityimagesearch.com/bot.php
 
Last edited:

fomalhaut

Member
Messages
107
Reaction score
0
Points
16
OK, learning_brain, that seems to satisfy me. I will test it as soon as possible.

Thanks.
 

deroba

New Member
Messages
10
Reaction score
1
Points
0
Yea, use PHP flushing, display an image and when page is fully loaded using JavaScript, make that image source change to the new one.
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
You might want to note that use of PHP ob_flush is not really the ideal solution in terms of server, user and browser friendliness. Basically, if the server is continuously sending data then the browser will never receive the full page contents and has to guess how the tags will be closed and will eternally say that the page is loading, as demonstrated learning_brain's page.
The ultimate solution to this sort of problem will always be reduced to an AJAX based communication with the server that'll inform the browser when to show the loading image and when to move the user on to the next page.
The problem that is causes on the browsers end is that the connection to the server is persistent and remains open until the entirety of the page has been transmitted: this means that the server could very easily become clogged with concurrent connections which could then reach the limit imposed by either Apache or any other software.
These are things you should keep in mind when you start designing this.
 
Top