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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:12:25+00:00 2026-05-17T02:12:25+00:00

I have a DB containing small news and a web app displaying these. I

  • 0

I have a DB containing small news and a web app displaying these. I would like to update my page every 60s with a jquery.ajax or jquery.getJSON request .

My question is how should I pass the last id i received from the server to the next ajax request so that i got only newer news? Where do I store it (on the DOM, into a global var, or hidden field, …)?

  • 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-17T02:12:25+00:00Added an answer on May 17, 2026 at 2:12 am

    Yes, you need to pass some argument that identifies the point from where to search for new records. This is typically handled by having the server return a sequential id or a timestamp with each Ajax response, such that the subsequent request will append this as an argument.

    You can store this value in various ways, but since these are typically single-page applications which are not reloaded, a simple JavaScript variable is often sufficient. You could also use closures as in the following example, instead of using a global variable:

    function fetchData(last_update_id) {
       $.ajax({
          url:      'fetch_data.php?last_update=' + last_update_id,
          method:   'GET',
          dataType: 'json',
          success:  function(data) {
             // Get the last_update_id from the server response.
             last_update_id = data.last_update_id;
    
             // Process your Ajax response...
    
             // Relaunch after 60s with the last_update_id argument.
             setTimeout(function () {
               fetchData(last_update_id);
             }, 60000);
          }
       });
    }
    

    If you go for this approach, you would initially call this function with a 0 or a -1 argument, or anything else as long as the server will understand that it is the first request. Then the function will auto manage itself, keeping the last_updated_id enclosed in a closure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many small files containing code fragments, pseudo-code algorithms, classes, templates, SQL-samples, etc.,
I have a small namespace containing some type definitions, which I use to make
I have a ListView containing file names. These file names need to be draggable
I have DataTemplate containing a TextBox . I'm setting this template to a listbox
I have div containing a list of flash objects. The list is long so
I have a column containing the strings 'Operator (1)' and so on until 'Operator
I have a dl containing some input boxes that I clone with a bit
I have a table containing prices for a lot of different things in a
I have two tables containing Tasks and Notes, and want to retrieve a list
I have a string containing a date, and another string containing the date format

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.