You can use the following simple code
php
//header('Content-Type: text/event-stream');
// recommended to prevent caching of event data.
header('Cache-Control: no-cache');
//long_process.php
for($i=1;$i<=3;$i++){
//do something
echo '
processing...';
ob_flush();
flush();
sleep(1);
}
echo 'CLOSE', 'Process complete';
?>
Or use as following
index.php
html>
<html>
charset="utf-8" />
/>
<input type="button" onClick="startTask()" value="Start Long Task" />
<input type="button" onClick="stopTask();" value="Stop Task" />
/>
/>
Results
/>
id="results" style="border:1px solid #000; padding:10px; width:300px; height:250px; overflow:auto; background:#eee;">
/>
id="percentage" style="text-align:right; display:block; margin-top:5px;">0
html>
manpreet
Best Answer
2 years ago
I have a php file which selects a large amount of data from mutiple sql table. Naturally it takes a long time to complete the whole process. I want to display a progress bar which will express the progress of the script running. How to display a progress bar? The script below shows a portion of the php file.