title: jQuery Ajax POST example with PHP
body: <p>I am trying to send data from a form to a database. Here is the form I am using:</p>
  
  <pre><code>&lt;form name="foo" action="form.php" method="POST" id="foo"&gt;
      &lt;label for="bar"&gt;A bar&lt;/label&gt;
      &lt;input id="bar" name="bar" type="text" value="" /&gt;
      &lt;input type="submit" value="Send" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The typical approach would be to submit the form, but this causes the browser to redirect. Using jQuery and <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a>, is it possible to capture all of the form's data and submit it to a PHP script (an example, <em>form.php</em>)?</p>