title: Use Ajax to call PHP function for HTML button Onclick
body: <p>I have a an HTML button where I want the onclick to call a PHP function. I need to use AJAX to do this but I am totally lost. There is more that occurs inside the php function, but I didn't see the need of including it. Below is code thus far:</p>
  
  <pre><code>&lt;HTML&gt;
  &lt;BODY&gt;
  &lt;FORM&gt;
      &lt;input text="text" name=airport1 id=airport1 /&gt;
      &lt;input text="text" name=airport2 id=airport2 /&gt;
      &lt;input type="button" value="Enter" onclick=PrintDist()/&gt;
  &lt;/FORM&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  
  &lt;?php
  
      function PrintDist(){
          $icao1 = $_REQUEST["airport1"];
          $icao2 = $_REQUEST["airport2"];
      }
  ?&gt;
  </code></pre>