title: Submitting a form without refreshing the page
body: <p>I'm having a problem with jQuery(or maybe php). I want forms to be submitted without refreshing the page so i ended up with the following code but the problem is it doesn't work. Here's the code:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
                  $("#submit").click(function() {
                  var name = $("#name").val();
  
                  var dataString = 'name='+ name;
  
                  $.ajax({
                  type: "POST",
                  url: "p.php",
                  data: dataString,
                  success: function(){
                      alert("It works");
  
                  }
                  });
                  return false;
  
              });
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form id="myForm" name="myForm" action=""&gt;
    &lt;p&gt;
      &lt;label for="name"&gt;&lt;/label&gt;
      &lt;input type="text" name="name" id="name" /&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;input type="submit" name="submit" id="submit" value="Submit" /&gt;
    &lt;/p&gt;
  &lt;/form&gt;
  &lt;br /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Processing Page:</p>
  
  <pre><code>&lt;?php include("../includes/includes.php"); ?&gt;
  &lt;?php $name = $_POST['name']; ?&gt;
  &lt;?php $sql = "INSERT INTO xyz 
          (id, value) VALUES 
              (1, '{$name}')";
          $result = $database-&gt;query($sql);
  ?&gt;
  </code></pre>