I'm following the example of php.net
<?php
header( 'Content-type: text/html; charset=utf-8' );
echo 'Begin ...<br />';
for( $i = 0 ; $i < 10 ; $i++ )
{
echo $i . '<br />';
flush();
ob_flush();
sleep(1);
}
echo 'End ...<br />';
?>
If I execute this script directly in the browser it counts from 1 to 10 showing its result correctly ...
But I have a textarea that receives the items, and ajax to send the post and search the result on the screen according to the result
More when I send the item, the flush does not work, it only returns the result at the end of
<script type="text/javascript">
$(document).ready(function() {
$("#enviar").click(function() {
var nome = $("#nome");
var nomePost = nome.val();
$.post("flush.php", {nome: nomePost},
function(data){
$("#resposta").html(data);
}
, "html");
});
});
</script>
<form action="" method="post">
<textarea name="nome" id="nome" cols="45" rows="5" required placeholder="Sua lista bla bla bla bla..."></textarea>
<br />
<br />
</form>
<button id="enviar" type="submit" class="ls-btn-primary ls-btn-xs">Check !</button>
<br>
</h6>
<br>
<div id="resposta"> Aguardando lista!</div>