Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
154
rated 0 times [  155] [ 1]  / answers: 1 / hits: 17107  / 13 Years ago, sun, november 13, 2011, 12:00:00

I have a page with a lot of images that are generated server-side depending on user actions. And when image loads successfully I'm happy, but when there is an error on the server I have to act according to what an error occurred.



For example:




  • 500 code: do this stuff.

  • 503 code: do that stuff



and so on.



So, my question: is there any way to get status code within img tag on-error event handler?


More From » image

 Answers
11

No, there is no way to get the HTTP status from a request made by an img tag in JavaScript.



You could write a firefox plugin, chrome/safari extension to do that.



An alternative would be using AJAX to load your images (not using img tags). You can get Http Status Codes from Ajax Requests.


[#89155] Friday, November 11, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jacklynr

Total Points: 542
Total Questions: 120
Total Answers: 95

Location: Cape Verde
Member since Fri, Nov 27, 2020
4 Years ago
;