-2

I am displaying an image on my web page which is present in the web-inf resources folder. When I click a button, a jquery ajax call is made to the server and the image in the web-inf folder is replaced with a new image but the name is same and immediately I want to display the new image instead of old image without reloading the webpage. I could do it by reloading but i don't want because all this is happening in a dialog. If I reload the dialog disappears. In the browser console I could identify that the url of img resource is pointed to new image only but the old image is being displayed. I also tried cache:false in ajax call.

Thanks in advance.

jagadeesh
  • 91
  • 8

1 Answers1

0

You want to append a timestamp to break cache:

newImage = "http://upload.wikimedia.org/wikipedia/commons/2/22/Turkish_Van_Cat.jpg?" + new Date().getTime();

Here is a fiddle: http://jsfiddle.net/kckekq6d/

This was adapted from this post. See it for more info.

Community
  • 1
  • 1
Peter Mark
  • 416
  • 2
  • 9