• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • 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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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