<?php
ob_start();
#ob_start('ob_gzhandler');
#ob_start('ob_deflatehandler');
header( 'Content-type: text/html; charset=utf-8' );
for ($i=0; $i<3; $i++) {
$arr = array('status' => TRUE, 'test' => 'TEST ' . date('Y-m-d H:i:s'));
echo str_pad(json_encode($arr), 4096);
ob_flush();
flush();
sleep(1);
}
ob_end_flush();
exit;
?>
Comet is a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it.
Reference:
http://stackoverflow.com/questions/3901495/what-is-the-best-way-of-showing-progress-on-an-ajax-call
https://en.wikipedia.org/wiki/Comet_%28programming%29
http://jpauli.github.io/2014/12/19/php-output-buffer-in-deep.html
http://stackoverflow.com/questions/4191385/php-buffer-ob-flush-vs-flush?rq=1
No comments:
Post a Comment