Is there a way though the DOM to test an image URL to see when it was last updated?
I am uploading an image to the web server. The image will replace a previous image with the same URL. I'm using plupload via ajax. When the upload is done, I want to update the image on the page.
I have tried using the FileUploaded event to trigger updating the src on the image. But I think it's either pulling the image from cache or it's firing faster than the web server can server the new image.
I know I could hack it by sleeping a couple of seconds. But I can think of all kinds of reasons why that would fail.
Is there a way to read a header from the file to tell if the file has changed on the server? Then I can keep asking until it does?
A more elegant solution would of course be better.
Since you say you're loading the image from the same URL, you need to trick the browser so it doesn't get the image from the cache. Appending the time should do it...
$("img").attr("src", "/image.png?t=" + (new Date().getTime()));