jQuery ajax: how to prevent 404 errors spam in chrome DevTools? [duplicate]

落花浮王杯 提交于 2019-12-03 08:19:48

问题


I'm communicating with CouchDB via jQuery ajax, and '404' errors are expected by REST contract. But for each requests that ends with '404', '412' or so, google chrome write a red error line in DevTools console, like this:

Is it possible to somehow configure jQuery so '404' is not an error for given request? Fake errors spam clutter output and i can miss real errors or some console.log while looking at hundreds of fake '404' and '412' "errors" :).


回答1:


This is not possible programmatically, due to the potential for a script to misuse the blocking or filtering of errors in the console to hide its activities from the Chrome user.

You can of course filter messages in the console by Error, Warn, Debug.

You can add your voice to those asking for more powerful capabilities to filter console messages in Chrome, so when you view the console you can filter out the messages that clog it up. One of the posts does offer a tool to tag your own console messages and then filter them.

If you want to highlight an error in the console, you can add styles to it when logging in your own code. E.g the following will make the message stand out:

console.log("%cUser %s has %d points", "color:orange; background:blue; font-size: 16pt", userName, userPoints);



回答2:


Bit of a necropost:

For the record, Chrome and Firefox have since added features that let you ignore network-specific errors.

In Chrome, click the filter icon to see the checkbox:

In Firefox, filters are broken down by category at the top of the window:



来源:https://stackoverflow.com/questions/16372271/jquery-ajax-how-to-prevent-404-errors-spam-in-chrome-devtools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!