title: How to use jquery ajax error parameter
body: <p>I'm looking for a simple example and/or explanation of how to use the <code>error</code> parameter for <code>.ajax</code>.</p>
  
  <p>This question (<a href="https://stackoverflow.com/questions/6792878/jquery-ajax-error-function">jQuery ajax error function</a>) points to this jQuery documentation (<a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow noreferrer">http://api.jquery.com/jQuery.ajax/</a>) which I do not understand.</p>
  
  <p>I have the following code that does not work and I can't figure out why.  I'm hoping the error parameter will help:</p>
  
  <p>jquery:</p>
  
  <pre><code> &lt;script&gt; 
      // wait for the DOM to be loaded 
      $(document).ready(function() { 
          // bind 'myForm' and provide a simple callback function 
          $("#myForm").submit(function(){
                  var user_input = $("#signup_id_email").val();
                  $.ajax
                  ({
                        type: "POST",
                        url: "ajax_test.php",
                        dataType: 'json',
                        data: {email: user_input},
                        **error: ""**
                  })
                  .done(function(r) 
                  {
                      $("#answer_id").append(r.email);
                  });
              });
      }); 
  &lt;/script&gt; 
  </code></pre>
  
  <p>PHP (ajax_text.php)</p>
  
  <pre><code>&lt;?php
  echo json_encode($_POST);
  ?&gt;
  </code></pre>