消除控制台中的 404 url 错误?
我尝试消除由于缺少源 (src) 而发生的 404 错误..
I try to eleminate an 404 error occuring because the source (src) is missing..
var $chart = $("<img />")
.addClass("trend-pic")
.error(function(){
console.log("error loading..")
});
try{
$chart.attr("src", jobs[counter].url + "test/trend")
}catch(err){
$chart.attr("src", "");
}
如果尝试了很多方法来捕获错误,即在末尾放置一个 .error(function(){})
.使用 $chart.load()
- 方法检查图像是否被加载?这些都没有帮助?
if tried many stuff to catch the error i.e. putting an .error(function(){})
at the end.
use the $chart.load()
- method to check if the images gets loaded?
Non of those helped?
GET {myURLString} 404(未找到)
浏览器:Safari
推荐答案
你不能真正从控制台中删除那些 404 错误.您可以做的最好的事情是进行一些 ajax 调用并查看返回码,但随后您将被限制为仅向您自己的域请求.
You can't really delete those 404 errors from the console. The best you can do is make some ajax calls and see the return code, but then you'll be limited to request only to your own domain.
编辑--
哦,是的,这些错误将继续显示在请求"标签中!它们只是不会出现在控制台"标签中(在 Chrome 中).
Oh, and yes, those errors will keep showing in the "Requests" tab! They just won't appear in the "Console" tab (in Chrome).
相关文章