形成ajax和ob_flush

I have this form :

<form id="monForm" action="indexer.php" method="post">
<input name="url" id="url" value="" class="url"/>
<input type="submit" id="envoyer" value="Parser" class="submit" />
</form>
<p id="infos"></p>

And this Javascript :

   <script>
   $(document).ready(function(){
       $('#monForm').submit(function() {

        var url = $('#url').val();
        $( "#result" ).empty();

        // appel Ajax
        $.ajax({
            url: $(this).attr('action'), // le nom du fichier indiqué dans le formulaire
            type: $(this).attr('method'), // la méthode indiquée dans le formulaire (get ou post)
            data: $(this).serialize(), // je sérialise les données (voir plus loin), ici les $_POST
            success: function(msg) { // je récupère la réponse du fichier PHP
                $('#infos').append(msg+'%<br/>');

            }
        });
        return false; // j'empêche le navigateur de soumettre lui-même le formulaire
    });
});                

My indexer.php is just a while :

$i = 0;
while($i < 10){
   echo $i."<br/>";
   sleep(1);
   $i++;
}

I don't want to return data (0, 1, 2, 3, ...) in 1 time.

I think that i need to use ob_flush but i don't know how to do this.

Any idea please ?

if you are trying to introduce a delay before printing the numbers, I think this code may help.

<?php 
header( 'Content-type: text/html; charset=utf-8' );

$i = 0;            
while($i < 10){
    echo $i."<br/>";
    if(sleep(1) != 0) {
        echo 'sleep failed';
        break;
    }
    flush();
    ob_flush();
    $i++;
}
?>

Hope this would be helpful for you:

<?php
// start output buffer
if (ob_get_level() == 0) ob_start();
$i = 0;
while($i < 10){
    echo $i."<br/>";
    ob_flush();
    flush();
    sleep(1);
    $i++;
}
?>