The best way to detect request abortion and avoiding false positive from offline mode :
$("#loading").ajaxError(function(event, xhr) {
if (xhr.status === 0) {
if (xhr.statusText === 'abort') {
// Has been aborted
} else {
// Offline mode
}
}
});