I've been updating one of my pet projects (a real-time photo site) and I'm trying to solve a small pet-peeve type of problem.
When the images are loading and the remote server fails in some way (returns a 500, a 404, etc) if the console is open you can see the failed requests.
Even when I capture the errors, the failed requests still show up. While this doesn't present any performance or issues with the app itself, it does annoy me a bit.
Wondering if anyone has an idea how to stop the logs from appea开发者_StackOverflow中文版ring, or if its just something baked into the browsers.
When I say console, I'm talking about the developer toolbars in Chrome, Safari, and Firefox (Firebug).
Here's one way that I load the images. Basically doing a pre-load and appending on complete:
$(new Image())
.load(function(){
$(this).appendTo( $('#container') );
})
.error(function(err){
//do whatever here. try/catch insider here doesn't stop the error from showing
})
.attr('src', imgsrc);
try {
$(new Image())
.load(function(){
$(this).appendTo( $('#container') );
})
.attr('src', imgsrc);
} catch(e) {
//code here
}
You could try that.
精彩评论