I have a script like this:
var img = $("<img />").attr('src', images[i]).load(function() {
alert(this.src); // old url
})
Sometimes the server will throw a 301 Moved Permanently
or 302 Moved Temporarily
HTTP code, and the actual image loaded will differ. How can I:
- detect if a redirection happened
- find out the new url -
this.src
doesn't take the redirect into account possibly prevent the new url from being loaded
?
[edit]
As per How to prevent ajax requests to follow redirects using jQuery, the last one is not possible. How can I find out the new URL?