$.ajax() calls success handler when network is down, v1.4.1.

$.ajax() calls success handler when network is down, v1.4.1.

Hello all,

It seems in jQuery 1.4.1 (haven't tested in other versions), doing an AJAX call while the machine is not connected to the internet results in a call to the success handler rather than the error one. Example run on Chrome 4/Windows 7:
  1. $.ajax({ url: 'http://www.google.com/',
  2.             type: 'GET',
  3.             error: function() { console.log('Error!'); },
  4.             success: function(x) { console.log('Success. Response: "' + x + '"'); },
  5.             complete: function(xhr) { console.log(xhr.status); } });

Output:
  1. Success. Response: ""
  2. 0

This is relevant to me because I'm using jQuery in a browser extension, and it should be able to gracefully handle the network being down. For now I'm using the complete handler and checking the XHR status, but that's rather inelegant when there is a proper error handler.