Image not reloading - using javascript with random url string added

Posted on 2010-11-09
Last Modified: 2012-05-10

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?


Question by:DrZork101
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 16

Accepted Solution

jmatix earned 500 total points
ID: 34095449
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
replacing inline javascript with jquery 4 63
close window in firefox 3 38
How does this modal gets closed? 6 42
Slow Down an Animation 3 29
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question