title: How to handle jQuery ajax post error when navigating away from a page
body: <p>Is there a way to handle the error from an ajax request within JQuery such that when the user navigates away from the page, the resulting error is ignored?</p>
  
  <pre><code>$(document).ready(function() {
   $.ajax( {
      url:'/server/url/',
      type: 'POST',
      data: {some..data},
      success:function(response) { do stuff with response },
      error: function(xhr, textStatus, errorThrown) {
             // Don't raise this alert if user has navigated away from the page
             alert('error');
      }
  });
  </code></pre>
  
  <p>I'm curious if anybody knows of a clean way to handle this? I know you could create some logic in a <code>$(window).bind("beforeunload", function(){})</code> method but I'd prefer if there was a way to handle the situation without doing this since Chrome appears to no longer support it. Is there for example a specific error that is returned in this case?</p>
  
  <p>Thanks.</p>