Jump to content

[SOLVED] delaying a script from running and having a animated load gif


robgood

Recommended Posts

hi,

 

I am looking to delay a script from running for about 8 seconds and display an animated gift load image while the delay is running.  This is just for a bit of fun really to give the illusion that something is processing in the background .  Is there any way in php to do this?

 

 

Liam, that code would simply spend a fraction over 8 seconds loading, then display the text 'script here img here'.

 

You can have output sent to the browser whilst the script is processing, if you use the flush function. For example:

 

<?php
for($x=1;$x<=5;$x++){
echo $x.'<br />';
flush();
sleep(1);
}
?>

 

With regards to the question, i agree with BlueSky. A delayed meta refresh would be better. Although, if you wanted to give the appearance of no reload, to enhance the 'illusion' of some loading time, then an AJAX approach would work more smoothly.

thanks, i have no clues about ajax so i am going to go with the meta refresh to another page option, as it's a multi purpose page, so presumably it would delay the page loading for each action, rather than just the last step.  It's a series of forms.

Archived

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

×
×
  • Create New...

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.