JQuery: How to distinguish 404 from other types of error on image load -



JQuery: How to distinguish 404 from other types of error on image load -

i need test if remote text file nowadays or not , wrapping in jsonp not option. ie ignores effort allow cross-domain ajax access default. 1 way around have read on set source of image object , see if generates error.

img = $('<img />',{ src: '/myfile.txt'}).bind('error', function(returned) {console.dir(returned);})

this doesn't work because text file not valid image. in case message displayed in console is...

resource interpreted image transferred mime type text/xml

if there no file error displayed in console is...

get http://example.com/myfile.txt 404 (not found)

both trigger error function if bind can't see way distinguish error of 2 beingness trapped. if drill "returned" object can see loads of stuff no mention of actual error message or 404 code looking for. how information?

jquery image cross-domain http-status-code-404

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -