title: can I use the submit button to activate an AJAX function?
body: <p>I have an HTML form that currently just posts the data directly to a PHP file.  I want to update the code so that the submit button sends the data to a JavaScript function so that I can create an AJAX function.  Is it possible for the submit button to activate a JavaScript function rather than posting to a php file?  The only thing I have come up with is below, which quite obviously does not work:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  function ajax(){
    //...
  }
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form action="ajax();"&gt;
    &lt;!-- ... --&gt;
    &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>