title: Execute php from javascript
body: <p>I'm having some trouble getting some php code working in my app.
  The setup is rather easy: 1 button, 1 function and 1 php file.</p>
  
  <p><img src="https://i.stack.imgur.com/qjHdP.jpg" alt="The structure"></p>
  
  <p>script.js</p>
  
  <pre><code>$(document).ready(function ()
  {
      $("#btnTestConnectie").click(testConnectie);
  });
  
  function testConnectie()
  {
      $.get("script/SQL/testConnection.php");
  }
  </code></pre>
  
  <p>testConnection.php</p>
  
  <pre><code>&lt;?php
  echo "It works!";
  php?&gt;
  </code></pre>
  
  <p>According to this post, it should work (<a href="https://stackoverflow.com/questions/1280767/how-do-i-run-php-code-when-a-user-clicks-on-a-link">How do I run PHP code when a user clicks on a link?</a>)</p>
  
  <p>Some sources claim that it is impossible to execute php via javascript, so I don't know what to believe.</p>
  
  <p>If I'm wrong, can somebody point me to a method that does work (to connect from a javascript/jQuery script to a mySQL database)?</p>
  
  <p>Thanks!</p>