I used the flush() function in an endless loop on my php page, it echoes the text every second. when I open the page in the browser, it works! but when i load it through jquery ajax it is not responding!
php page
<?php if (ob_get_level() == 0) ob_start(); for ($i = 0; true; $i++){ echo "<br> Line to show. $i"; echo str_pad('',4096)."\n"; ob_flush(); flush(); sleep(1); } ob_end_flush(); ?>
Jquery code
$.ajax({ url: 'res.php', beforeSend: function( ) { $('#mydiv').html('loading...'); }, success: function( data ) { $('#mydiv').html( data ); } });
user421125
source share