Refresh div if PHP page returns true?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/9571447/jquery-refresh-if-php-file-echos-true">jQuery refresh if PHP file echo&#39;s &#39;true&#39;</a>  </p>
</blockquote>



<p>I have the following div on my index:</p>

<pre><code>&lt;div id='tv'&gt; &lt;? include 'tv.php' ?&gt; &lt;/div&gt;
</code></pre>

<p>I have a script that changes content in tv.php and returns 'true' at a certain time called checktime.php.</p>

<p>I'm trying to have jQuery in the index header to check the PHP page every 10 seconds and if checktime.php returns 'true' jQuery 'refreshes' the content of the #tv div. This is the code I currently have but it's not working. It seems to check checktime.php but the div doesn't automatically refresh.</p>

<pre><code>&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
$(document).ready(function(){
    setInterval("checkTime()", 10000);
    function checkTime(){
        $.ajax({
            url: 'checktime.php',
            success: function(refresh){
                if($.trim(refresh) == "true"){
                    $('#tv').load('tv.php');
                }   
            }
        });
    }

});
&lt;/script&gt;
</code></pre>
