title: call php file from javascript
body: <p>Hi I have searched the web but can't get this to work. I'm trying to call the file <strong>databaseUpdated.php</strong> (placed in the same folder as the <strong>index.php</strong> file) from a function that is called every 10 seconds.</p>
  
  <p>If I place the following in the index.php</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;updateboolean();&lt;/script&gt;;
  </code></pre>
  
  <p>the function is runned so thats not the problem, the problem is that the php file is not read.</p>
  
  <p>the file <strong>databaseUpdated.php</strong></p>
  
  <pre><code>&lt;body&gt;
  &lt;?php
  
  echo ("&lt;script type='text/javascript'&gt;updateboolean();&lt;/script&gt;;");
  
  ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>And here is my functions in the javascript</p>
  
  <pre><code> $(document).ready(function(){
          setInterval(function() {
          $.get("databaseUpdated.php");//Can't get this to work any obvious reason for this (And yes I have jquery working)?
          return false;            
      }, 10000);
      });
  
  
  
      function updateboolean(){
          alert("Database updated");
          document.location.reload(true);
      }
  </code></pre>
  
  <p>Thanks in advance =)</p>
  
  <p>Edit</p>
  
  <p><strong>_________________________________________________________________________________________</strong></p>
  
  <p>When I do</p>
  
  <p>alert(data); in the below function I get the result as the image will show</p>
  
  <pre><code>$(document).ready(function(){
              setInterval(function() {
                 $.get('databaseUpdated.php', function(data) {
                 alert('Load was performed.');
                 alert(data);
                 eval(data);
              });
          }, 5000);
     });
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/IaJcE.jpg" alt="enter image description here"></p>
  
  <p>But the "<strong>eval(data)</strong>"
  doesn't seem to work</p>