title: Advanced Call Php Function From Javascript
body: <p>Here is my code.</p>
  
  <pre><code>&lt;script&gt;
    function test(div_id) {
      var newMail = '&lt;?php echo count_new_mail($id); ?&gt;';
      setTimeout(test, 10000);
    }
    test();
  &lt;/script&gt;        
  </code></pre>
  
  <p>What I want to do is call the php function count_new_mail every 10 seconds. When the javascript is made by the php the result looks like this.</p>
  
  <pre><code>var newMail = 1;
  </code></pre>
  
  <p>I know this is because it ran the php and count_new_mail gave a value of 1. How do I get this javascript to call the function every 10 seconds and not just keep the same value? Or will I have to write the php function as a javascript function and call that to get the results I want?</p>