I am trying to refresh an image on the page but it is not happening. I have a page with images and I need to update those images as required. To update an image I upload the image on a lightbox and then close the lightbox. The image on the page should update itself. Now, I tried $('#imageid').attr('src', newimage). I want to make a special mention here that the name of both the old and new images are same. And I feel this is the problem. If I hard code any other image it does appear as soon as the lightbox closes. But, when I try to refresh the image by putting the same image name for the 'src' attribute then nothing happens.
Can someone help me out how I can fix this issue and show the updated image.
Thanks.
Edit: Could it be the cache?
There's probably a better solution, but you could just throw on a parameter to force a new image load.
i.e.: Set the src to newImage+"?"+(new Date()).getTime()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With