$(function() { $(document).ajaxError(function(event, response, ajaxSettings, thrownError) { if (response.statusText === "abort") { // we do not catch aborted calls return; } switch (response.status) { case 422: // we leave 422 handling to individual calls break; case 500: default: swal({ title: 'Whoops!', text: 'We encountered a problem. Please contact technical support.', type: 'error' }); break; } }); });