HTTP Request showing progress on background task without ajax

November 17, 2016

The idea: show progress for process that is running in the background
Execution: takes advantage of the fact that JavaScript is loaded in parallel

@header('Content-Encoding: text/html');

echo 'I am doing some very very very long job 
'; $taskId = uniqueId(); touch($taskId); echo ''; echo 'Doing it '; while (file_exists($taskId)) { echo '|'; sleep(5); } echo '
'; /** * Job done, do something else */

P.S. Dont forget to unlink the file when the background task is done

Simple as that.

posted in Uncategorized by Ivan Gospodinow

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /home/c2kblate/sites/ on line 1048
Powered by Wordpress and MySQL. Theme by Shlomi Noach,