Endless loop in jQuery and PHP. What should I change to make it work?
<pre><code>&lt;?
if($_POST['begin'])
{
    while(1)
    {
        echo "1";
        sleep(2);
    }
    die();
}
?&gt;

&lt;span class="answer"&gt;&lt;/span&gt;

&lt;script type="text/javascript"&gt;
$(document).ready(function() {
        $.ajax({
            type: "POST",
            url: "exp.php",
            data: "begin=1",
            success: function(msg){
                $(".answer").html(msg);
            }
        })  
})
&lt;/script&gt;
</code></pre>

<p>It, of course, doesn't work. What should I change to make it work? Can I avoid using setInterval, setTimeout or other functions in javascript?</p>

<p>By the way, what I am trying to do here is to write number 1 every two seconds.</p>
