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.
put this in the top of your page:
<script>
$(document).ready(function() {
jQuery.migrateMute = true;
})
</script>
its temporary - but worked for me. Beats having to scroll through 45 lines of nonsense to debug js errors.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.