title: jQuery AJAX form submit error working success not
body: <p><strong>EDIT</strong></p>
  
  <p>Ok, so I can login fine but when I enter false info I'm redirected to the login page, what I need is to stay on the same page and show the error message <code>e.preventDefault();</code> doesn't seem to work.</p>
  
  <pre><code>   $(function() { 
      $("#login-form").submit(function(e) { 
          $('.fail').hide();
          $.ajax({  
              url:"/login",
              type: "post",  
              data: $(this).serialize(),
              error:function(){
                  $('.fail').show();
                  e.preventDefault();
              },
              success: function(){ 
                  document.location = '/'; 
                  }
          });
          return false; 
      });
  });
  </code></pre>