title: Ajax submitting form doesn't reload page but doesn't post
body: <p>Help, I am really not familiar with ajax and I wanted to submit a form without reloading the page. Using the codes below, it didn't reload but it certainly didn't post or didn't even call the ajax function.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function() {
  
  //this submits a form
      $("#post_form").on("submit", function (e) {
              e.preventDefault();
             $.ajax({
                 type: "POST",
                 url: "post.php",
                 data: $("#post_form").serialize(),
                 beforeSend: function() {
                     $('#input_process').html('Loading');
                 },
                 success: function(data) {
                     $('#input_process').html(data);
                 },
                 failure: function(){
                      $('#input_process').html('Failed');
                 }
  
              })
      })
  })
  
  &lt;/script&gt;
  </code></pre>
  
  <p>And here is the html form codes</p>
  
  <pre><code>&lt;div id="input_process"&gt;&lt;/div&gt;
                      &lt;div id="story_post_input"&gt;
                          &lt;form name="post_form" id="post_form" action="" method="POST"&gt;
                              &lt;input type="hidden" name="post_type" value="story" /&gt;
                              &lt;input type="text" name="post_title"/&gt;
                              &lt;textarea name="userpost"&gt;&lt;/textarea&gt;
                              &lt;input type="submit" name="post_submit" value="post" id="post_submit_button"/&gt;
                          &lt;/form&gt;
                      &lt;/div&gt;
                      &lt;div id="shout_post_input"&gt;
                          &lt;form name="post_form" id="post_form" action="" method="POST"&gt;
                              &lt;input type="hidden" name="post_type" value="shoutout" /&gt;
                              &lt;input type="text" name="userpost"/&gt;
                              &lt;input type="submit" name="post_submit" value="shout" id="post_submit_button"/&gt;
                          &lt;/form&gt;
                      &lt;/div&gt;
                      &lt;div id="image_post_input"&gt;
                          &lt;form name="post_form" id="post_form" action="" method="post" enctype="multipart/form-data"&gt;
                              &lt;input type="file" name="post_image"&gt;
                              &lt;input type="hidden" name="post_type" value="image" /&gt;
                              &lt;input type="text" name="userpost"/&gt;
                              &lt;input type="submit" name="post_submit" value="upload" id="post_submit_button"/&gt;
  
                          &lt;/form&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>And here is the post.php code</p>
  
  <pre><code>&lt;?php
      if(isset($_POST['userpost'])){
          $post_type = $_POST['post_type'];
          if($_POST['post_type']=="shoutout"){
  
              $post = $_POST['userpost'];
              $query = 'INSERT INTO tblpost (post_content, post_date, post_userID, poster, post_type) VALUES ("'.$post.'", now(), "'.$_SESSION["user_ID"].'", "'.$_SESSION["username"].'", "'.$post_type.'" )';
              $result = mysql_query($query) or mysql_error();
              $tmp_post_ID = mysql_insert_id();
              $type = "post";
              notify($type, $tmp_post_ID);
  
          }
          if($_POST['post_type']=="story"){
              $post_title = $_POST['post_title'];
              $post = $_POST['userpost'];
              $query = 'INSERT INTO tblpost (post_content, post_date, post_userID, poster, post_type, post_title) VALUES ("'.$post.'", now(), "'.$_SESSION["user_ID"].'", "'.$_SESSION["username"].'", "'.$post_type.'", "'.$post_title.'" )';
              $result = mysql_query($query) or mysql_error();
              $tmp_post_ID = mysql_insert_id();
              $type = "post";
              notify($type, $tmp_post_ID);
  
  
          }
          if($_POST['post_type']=="image"){
              $tmp_name = $_FILES['post_image']['tmp_name'];
              $user_ID = $_SESSION['user_ID'];
              $post = $_POST['userpost'];
              $img_ID = upload_image($tmp_name,$user_ID);
              $query = 'INSERT INTO tblpost (post_content, post_date, post_userID, poster, post_type, img_ID) VALUES ("'.$post.'", now(), "'.$_SESSION["user_ID"].'", "'.$_SESSION["username"].'", "'.$post_type.'", "'.$img_ID.'" )';
              $result = mysql_query($query) or mysql_error();
              $tmp_post_ID = mysql_insert_id();
              $type = "image";
              notify($type, $tmp_post_ID);
  
  
          }
          //header('location:'.curPageURL());
      }
  
  ?&gt;
  </code></pre>