Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7057915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:03:01+00:00 2026-05-28T04:03:01+00:00

I have some images from another source that need to refresh from their offsite

  • 0

I have some images from another source that need to refresh from their offsite source every 30 seconds. I would like to use JavaScript to accomplish this so as to avoid an entire page reload.

Presently I’ve attempted something similar to this question: “reloading a page after every 10 sec in rails 3.1”

(This is a Rails application, but I probably don’t need a Rails specific answer in this case.)

Notwithstanding, I am ending up with no appreciable result when I add a div around the link + image nor when I add a div to the image itself. I have attempted both solutions in this example by creating a element-reload.js.

The first solution that’s marked as the answer simply reloads the page with nearly all of the page elements absent. The second solution makes the image that I’m trying to refresh actually disappear upon first refresh when I surround the link + image with a div, but when I place the id upon which it’s acting on the actual image tag, it yields nothing.

I’m sure I’m missing something rather simple since JS is not a strong suit for me at the moment.

Finally, I do have a number of sources to refresh and would like to see an example of performing this for a class vs an id if possible, but having more granular control over each one may be best in the end for varied times for the refreshes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:03:02+00:00Added an answer on May 28, 2026 at 4:03 am

    If you’re up for jQuery, this can be done quite easily:

    $(function() {
      setInterval(function() {
        $('img').each(function() {
          $this = $(this);
    
          $this.attr('src', $this.getAttribute('src') + '?timestamp=' + new Date().getTime());
          console.log($this.prop('src'));
        });
      }, 30 * 1000);
    });
    

    In order to prevent browser caching, you have to fool the browser and load the image with a GET request variable timestamp. It doesn’t matter what the parameter is, but the image will load brand-new and not from cache because the URL changes.


    jQuery is famous for its use of CSS-like selectors.

    Replace $('img') with one of these:

    $('img.yourClassName'); // Class
    $('#your_id, #another_id, ...'); // ID(s). Omit the comma for a single id
    $('img[id^="common_base_id"]'); // Selects all images with an id that starts with "common_base_id".
    

    There’s also the :not() selector, which can filter your results:

    $('img.yourClassName:not(.do-not-reload)');
    $('img.yourClassName:not([src="img/spinner-skip.gif"])');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a thread that downloads some images from internet using different proxies. Sometimes
I have some images that need to change, based not only on hover, but
I have some code that downloads an image from a remote server $data =
I have some static images in a folder on my IIS 6-based website that
I have some text/images that I only want to display in the normal state
I have some static resources (images and HTML files) that will be localized. One
I have some large files (images and video) which I need to store in
I'm dealing with OpenCV and have some memory management questions from their DFT example
So I'm trying to grab some images from another site, the problem is each
This is borrowed from another question I made on the site, but would have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.