I am using the following jQuery JSONP request to check the status of a resource by URL. When the resource is not available or the server is down, my ajaxFail() function updates the display.
function fetchServerStatus(service, host)
{
var port = serverStatus[service].port;
$.ajax({
url: "http://" + host + ":" + port + "/admin/server/status",
dataType: "jsonp",
timeout: 1000,
error: ajaxFail,
fail: ajaxFail,
success: ajaxDone,
done: ajaxDone,
complete: ajaxAlways,
always: ajaxAlways
});
}
The problem I’m having is that despite declaring handlers for fail and error, which do not log anything to the console, jQuery always logs the failed request in the console. If the resource is unavailable for a long time, this builds up a huge console log, eventually crashing the browser process (Chrome in my case).
Is there any way to stop it from doing this?
The logging entry in chrome’s console is a behaviour of chrome when any HTTP request is handled, not a problem with jQuery or ajax(XMLHttpRequest), even an
<img>or<link>tag could cause this issue.Your only choice is to fix your server-side code not to trigger an error for ajax (eg. 404 not found or wrong content-type), so based on the content logged to console, maybe a better solution could be found, please provide accurate logging message in your console.