• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

Image not reloading - using javascript with random url string added


I am changing an image to an ajax spinner, uploading a new image, changin the image back to the original url + a random string to avoid caching.

However, the image does not always update and sometimes needs a reload.

How can I can it to always show the new image?


1 Solution
Justin MathewsCommented:
Your logic should work since every time you are setting the <img> src to a unique value. I guess sometimes browser fails to update the image. If it is in your control I would say change the image name that you upload - something similar to the following:

                                    src     : '../images/imageLoader.gif',
                                    width   :'31',
                                    height  :'31'
          var dummy = Math.floor(Math.random()*9999999);
                                    src     : '../images/archive/'+intDay+dummy+'img'+imageId+'.jpg',
                                    width   :'140',
                                    height  :'90'

Open in new window


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now