title: How can I execute a PHP function via ajax?
body: <p>How do I execute a PHP function using ajax? I have multiple functions on my script page but I want to call a single function.</p>
  <pre><code>&lt;?php
      function one(){return 1;}
      function two(){return 2;}
  ?&gt;
  </code></pre>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$("#form").on('submit',(function(e){
      e.preventDefault();
      
      $.ajax({
          url: "process.php",
          type: "POST",
          data: new FormData(this),
          contentType: false,
          cache: false,
          processData:false,
          success: function(response){
              alert(response);
          }
      });
  }));</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
  
  &lt;form action="" method="POST" id="form"&gt;
      &lt;input type="text" name="text" id="text" /&gt;
      &lt;button type="submit" id="submit"&gt;Upload&lt;/button&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>