title: jQuery & Ajax: catching a 500
body: <p>I have this jQuery code that send an Ajax request on a form submit. My issue is I can't catch timeout error using that code. When I send a 500 response myself it is working but if I get a timeout then I see 500 in the console but nothing happens, the error callback is not executed. Instead I get :</p>
  
  <blockquote>
    <p>SyntaxError: syntax error</p>
  </blockquote>
  
  <p>On the line: </p>
  
  <blockquote>
    <p>$(document).ready(function(){</p>
  </blockquote>
  
  <p>Here is the full code:</p>
  
  <pre><code>$(document).ready(function(){
      $('body').on('submit', 'form#myForm', function(){
          $.ajax({
              type: "POST",
              url: $(this).attr('action'),
              data: $(this).serialize(),
              dataType: 'json',
              success: function(data, textStatus, jqXHR){
                  alert('success!');
              },
              error: function(jqXHR, textStatus, errorThrown){
                  alert('error!');
              }
          });
          return false;       
      });
  });
  </code></pre>