为什么即使在onError处理程序捕获到异常后,chrome仍会记录缺失图像的404(Not Found)错误? [英] Why does chrome still log 404 (Not Found) errors for missing images even after an onError handler has caught the exception?

查看:444
本文介绍了为什么即使在onError处理程序捕获到异常后,chrome仍会记录缺失图像的404(Not Found)错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考此问题:用于替换损坏图像的jQuery / JavaScript

我仍然在Chrome控制台中获得这样的例外,即使使用上述链接解决方案的建议正确地重新生成图像时:

I still get exceptions like this in chrome console, even when when the images are being correctly repalced using the suggestions from the linked solution above:

GET http://10.10.0.3/OC/media/profile-pics/2348022002298.jpg 404 (Not Found)

我正在建立一个大型地址簿,用手机号码保存图像。可能存在1000个404错误。

I'm an building up a large address book where images are saved by mobile number. there would potentially be 1000's of 404 errors.

这是性能问题 - 1000次失败的图像下载尝试?

Would that be a performance issues - 1000's of failed image download attempts?

链接中建议的解决方案是否更有效?

IS there a more efficient solution to that suggested in the link?

到目前为止,我最好的替代方案似乎构建了这个服务器端并提前替换文件我无法找到的文件的时间。

My best alternative so far seems to build this up server-side and do a file replace ahead of time for files i cant find.

建议请,谢谢。

推荐答案

因为http请求仍然失败。

Because the http requests still fail.

失败后你使用替换,但这不像阻止异常抛出 up。

After they fail you use the replacement, but it's not like preventing an exception to throw up.

进一步解释,使用@ RGraham的评论如下:

To further explain, using @RGraham's comment below:

控制台显示多种类型的错误。其中

the console shows errors of many types. Among which


  • Javascript异常,除非得到处理。

  • 返回错误状态的网络请求(4xx,5xx)

  • Javascript exception, unless handled.
  • Network requests which return with error status(4xx,5xx).

后者就是你的情况。在这种情况发生后,你有一个解决方案,但它们确实会失败。

The latter is your case. After this happens, you have a solution, but they do go and fail.

这篇关于为什么即使在onError处理程序捕获到异常后,chrome仍会记录缺失图像的404(Not Found)错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆