Question

I have tried to get several examples that I have found on here and the internet with out success.

Goal: To display a animated gif while php scripts run.

Background: This page is loaded via iframe. The php script I have tests 3 vpn connections and then displays a check (good) or an X (bad). The php portion works, but since there is a delay while testing I want to display the animated gif progress bar.

Running Apache on CentOS 5.7

Currently this is done in a single file named: status.php

I thank you in advance for any assistance.

Roger

Was it helpful?

Solution

You can flush the buffer to the browser while PHP is still processing.

echo "Loading";
flush();

sleep(10); // Simulate long process time
echo "Finished";

OTHER TIPS

The trick to doing it is not to actually open the PHP file in the iframe. Yeah, seems count intuitive, doesn't it?

Your iFrame should be a page that contains the animated gif and some javascript that will make a call to the php server, get the results, and change the animated gif to the results of the script.

Resolved the challenge:

1) Added this to status.php

http://pastebin.com/KR1zPezG

So the iframe loads status.php --> shows the gif --> Loads status2.php --> displays results

NOTE: the pastbin contents are pretty much the whole status.php file, other than the html /html tags.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top