title: Script not executed when submitting form
body: <p>I have a form and want to send the form data to a PHP file using Ajax:
  This is my form:</p>
  
  <pre><code>&lt;div class="acc_content clearfix"&gt;
                                          &lt;form name="contactForm" id="contactForm" class="nobottommargin" action="guarda_pass.php" method="post" &gt;
                                              &lt;div class="col_full" style="color: #898989"&gt;
                                                  &lt;label style="color: #898989" for="login-form-username"&gt;Escribe tu nueva contraseña:&lt;/label&gt;
                                                  &lt;input type="text" id="password" name="password" value="" class="form-control" required /&gt;
                                              &lt;/div&gt;
                                              &lt;div class="col_full" style="color: #898989"&gt;
                                                  &lt;label style="color: #898989" for="login-form-username"&gt;Confirma tu nueva contraseña:&lt;/label&gt;
                                                  &lt;input type="text" id="con_password" name="con_password" value="" class="form-control" required/&gt;
                                              &lt;/div&gt;
  
  
                                              &lt;div class="col_full nobottommargin"&gt;
                                                  &lt;button class="button button-3d button-black nomargin" style="background-color: #6fb6e5"  type= "submit"  value="login"&gt;Registrar&lt;/button&gt;
  
  
                                              &lt;/div&gt;
                                          &lt;/form&gt;
                                            &lt;div id="contactResponse"&gt;&lt;/div&gt;
                                      &lt;/div&gt;
  </code></pre>
  
  <p>And this is the script:</p>
  
  <pre><code>&lt;script src="js/jquery.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              $("#contactForm").submit(function(event) 
              {
                  /* stop form from submitting normally */
                  event.preventDefault();
  
  
                  /* get some values from elements on the page: */
                  var $form = $( this ),
                  $submit = $form.find( 'button[type="submit"]' ),
                  password_value = $form.find( 'input[name="password"]' ).val(),
                  con_password_value = $form.find( 'input[name="con_password"]' ).val(),
                  url = $form.attr('action');
  
                  /* Send the data using post */
                  var posting = $.post( url, { 
                      password: password_value, 
                      con_password: con_password_value 
                  });
  
                  posting.done(function( data )
                  {
                      /* Put the results in a div */
                      $( "#contactResponse" ).html(data);
  
                      /* Change the button text. */
                      $submit.text('Sent, Thank you');
  
                      /* Disable the button. */
                      $submit.attr("disabled", true);
                  });
              });
          &lt;/script&gt;
  </code></pre>
  
  <p>After clicking the submit button, the page reloads itself and the script is not executed.
  What am I doing wrong?</p>