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 9255009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:36:55+00:00 2026-06-18T11:36:55+00:00

I made this script to get some json information: $(document).ready(function(){ $.ajax({ url: ‘url’, dataType:

  • 0

I made this script to get some json information:

 $(document).ready(function(){

    $.ajax({
      url: 'url',
      dataType: 'json',
      cache: true,
      timeout: 30000,
      success: function(data) {

            // $('#output ul').append('<li>The feed loads fine');
            $('#output ul').empty();

            $.each(data.posts, function(i,data){ 

                $('#output ul').append('<li><a href="'+data.image+'"><img class="thumb" src="'+data.image+'" alt="" /></a><h3>'+data.title+'</h3><p>'+data.text+'</p></li>');


            });

        },
        error: function(){
            $('#output ul').append('<li>Error');
        }
    });
 });

But i want to update the feed every x seconds. I read a lot about it but i can get it done.

How can i do this?

  • 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-06-18T11:36:56+00:00Added an answer on June 18, 2026 at 11:36 am

    Use setInterval to repeated call the code block, and put your code in some function and pass the function name to setInterval first parameter. You can pass anonymous function instead of making a new function like repeatMe but I would prefer making function to make the code more readable.

    function repeatMe(){
     $.ajax({
      url: 'url',
      dataType: 'json',
      cache: true,
      timeout: 30000,
      success: function(data) {
    
            // $('#output ul').append('<li>The feed loads fine');
            $('#output ul').empty();
    
            $.each(data.posts, function(i,data){ 
    
                $('#output ul').append('<li><a href="'+data.image+'"><img class="thumb" src="'+data.image+'" alt="" /></a><h3>'+data.title+'</h3><p>'+data.text+'</p></li>');
    
    
            });
        },
        error: function(){
            $('#output ul').append('<li>Error');
        }
     });
    }
    
    setInterval(repeatMe, 5000);
    

    Edit It would be better to use setTimeout instead of setInterval in the success to send the next call for update after the first has finished its job. We will also put setTimeout in error to keep the repetive call for update.

    function repeatMe(){
     $.ajax({
      url: 'url',
      dataType: 'json',
      cache: true,
      timeout: 30000,
      success: function(data) {
            // $('#output ul').append('<li>The feed loads fine');
            $('#output ul').empty();
            $.each(data.posts, function(i,data){ 
    
                $('#output ul').append('<li><a href="'+data.image+'"><img class="thumb" src="'+data.image+'" alt="" /></a><h3>'+data.title+'</h3><p>'+data.text+'</p></li>');
                setTimeout(repeatMe, 5000);
            });
        },
        error: function(){
            $('#output ul').append('<li>Error');
            setTimeout(repeatMe, 5000);
        }
     });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this bookmarklet: javascript:(function(){var s=document.createElement('script');s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');document.getElementsByTagName('body')[0].appendChild(s);$('#hldIntMain').hide();$('#fadeBackground').hide();return false;})() Formatted code: // Add in jQuery var
I've made jQuery & AJAX script that uses a PHP function to bring back
I made a chrome extension which calls jQuery's ajax method: content-script.js [...] $.ajax({ url:
Hi I have recently made this script to rename files I scan for work
I made this Greasemonkey script: var maxpi = 250; var p1 = /html/body/div/div[2]/div/div[2]/table[2]/tbody/tr[1]/td[11]; var
The html of this script is made with list items http://www.jeremymartin.name/projects.php?project=kwicks Where can I
I made this function to verify a user's twitter credentials. Its running on two
I made this little function from code snippets around the net. It does what
I am using jQuery's $.ajax method to retrieve some JSON from an API. Each
I have made a chat script using php, mysql and jquery. It uses json

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.