title: how to run php function without reloading the page
body: <p>I am a newbie to php</p>
  
  <pre><code>   &lt;?php
      getDBData(){
          //log the call
          $fetchedData = myDbCode.fetchData();
          return 
      }
    ?&gt;
    &lt;script type="text/javascript"&gt;
        dbData = &lt;?php echo json_encode(getDBData()); ?&gt;
    &lt;/script&gt;
  </code></pre>
  
  <p>As observed in the log that getDBData get called only once during the page loading and later on even with <code>dbData = &lt;?php echo json_encode(getDBData()); ?&gt;</code> this code the call to <code>getDBData()</code> doesn't happen.</p>
  
  <p>Any idea why the call to getDBData() happening only on page load and not thenafter</p>
  
  <p>How to call <code>getDBData()</code> from javascript</p>