i'm trying show function status looping delete previous status before next 1 shows. current code:
<?php @ini_set('zlib.output_compression',0); @ini_set('implicit_flush',1); @ob_end_clean(); set_time_limit(0); // perform 1st function here echo "retrieving data..."; echo str_repeat(' ',1024*64); sleep(1); // perform 2nd function here echo "analyzing data..."; echo str_repeat(' ',1024*64); sleep(1); // perform 3rd function here echo "done..."; echo str_repeat(' ',1024*64); sleep(1); // clean echos here.. ?> <html> <head> // dynamic head content result of php functions above </head> <body> </body> </head> now works, displays echos 1 after other. i'd next status replace first, until end, remove "done" before html displayed.
i tried:
ob_start(); echo "retrieving data..."; echo str_repeat(' ',1024*64); sleep(1); ob_end_clean(); but didn't work. possible @ all?
the following uses last-of-type pseudo css selector hide old progress status messages. it's reasonably new selector doesn't work on older browsers (pre ie9), can check compatibility on mozilla developer network
<html> <head> <style type="text/css"> #progress span { display: none; } #progress span:last-of-type { display: block; !important } </style> </head> <body> <div id="progress"> <?php ($i =0; $i<=100; $i+=10) { ob_start(); echo "<span>$i%</span>"; ob_end_clean(); sleep(1); } ?> </div> </body> </html>
Comments
Post a Comment