Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.