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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:25:14+00:00 2026-06-04T21:25:14+00:00

I normally develop with VBA and MySQL, but have been tasked with creating a

  • 0

I normally develop with VBA and MySQL, but have been tasked with creating a live dashboard to be put on screens around my office. For this I’m using PHP and javascript. The dashboard contains two main sections, one calls website traffic data through the google analytics API, the other calls sales data from our internal DB.

I have the seperate halves written in PHP in seperate modules that I’m calling with the code below from the dashboard webpage, using a loop to refresh each module independently every ten seconds. The problem is that I’d like to include two timers on the screen counting upwards in seconds from the last time each of the modules was loaded, I’m using the following code to try and reset a variable with the current time to facilitate this when each document is loaded.

var sales_string_unix = 0;
var sales_string_google = 0;

setInterval(function(){

    $(document).ready(function() {
        $('#google_data').load('fetch_google_data.php');
        sales_string_unix = new Date().getTime();   
    });

 }, 10000); 

setInterval(function(){

    $(document).ready(function() {
        $('#sales_data').load('fetch_sales_data.php');
        sales_string_google = new Date().getTime(); 
     });

}, 10000);

My problem is that the timestamp variables reset every ten seconds when the loops execute, rather than when the modules are refreshed. So far 6hrs of Google has returned nothing useful and I expect I’m probably missing something simple thats just outside of my experience. Any help would be appreciated, thanks in advance.

  • 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-04T21:25:17+00:00Added an answer on June 4, 2026 at 9:25 pm

    You need to put the timestamp update code in the callback function of the load() which runs when the AJAX call has completed. You also don’t need the document.ready handler inside each function. Try this:

    var sales_string_unix = 0;
    var sales_string_google = 0;
    
    setInterval(function(){
        $('#google_data').load('fetch_google_data.php', function() {
            sales_string_unix = new Date().getTime();  
        });          
    }, 10000); 
    
    setInterval(function() {
        $('#sales_data').load('fetch_sales_data.php', function() {
            sales_string_google = new Date().getTime(););
        });
    }, 10000);
    

    Be aware however, that those variables will only be filled once the AJAX call has completed, so you cannot use them directly after the AJAX calls themselves. You would need to run or call the code which relies on the timestamps from within the callback function itself.

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

Sidebar

Related Questions

I've been using Dreamweaver to develop PHP and MySQL based websites, but as it
I normally develop with a live server, but for the first time I figured
We develop mostly low traffic but highly specialized web applications. Normally we use L2S,
Normally it is possible to apply data validation in excel through vba but i
I read about WPF and I have following concerns: Normally when we develop applications
As I like to develop some applications for Palm OS, normally I have problems
I have been trying to develop some user controls, one being a text edit
First post here... I normally develop using PHP and Symfony with Propel and ActionScript
I develop websites since last two years now and I have hard time learning
I have been looking at whether our MSDN Premium Subscriptions would cover upgrading our

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.