I\'m loading an image path via jQuery $.ajax and before showing the image I\'d like to check if it in fact exists. Can I use the image load/ready event or something similar
$.get( 'url/image', function(res){
//Sometimes has a redirect to not found url
//Or just detect first the content result and get the a keyword for 'indexof'
if ( res.indexOf( 'DOCTYPE' ) !== -1 ) {
//not exists
} else {
//exists
}
});