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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:04:50+00:00 2026-05-31T07:04:50+00:00

I have data grids on my webpage that need to be refreshed every few

  • 0

I have data grids on my webpage that need to be refreshed every few minutes. The data is queried from a mysql database using PHP when a Javascript timer expires. Once the data is imported it needs to be styled to make the problems easily visible, so I trigger another timer that will rollover every 2.5 seconds for a total of three times and then turn off. I came up with that solution because the data grids were not populated immediately, so running it after the queries with no delay caused it to miss most of the data.

Problems:
1) The biggest problem is if the webpage remains open in a browser when the computer goes to sleep, there are several empty alerts. Given how many people will be using this website at work, this behavior is totally unacceptable. I’m out of ideas.

2) I wish there was a better way to deal with the data upon import so I wouldn’t have to $(“td”).each() the entire page after a refresh. I am using components from the dhtmlx library, so it’s a little hard to crack open the functions and deal with this internally. Post-processing the data was all I could really do to make it work, but I’m open to ideas.


Variable declarations and initial timer settings:

//Set a timer to refresh all grid data every 4 minutes
var RefreshDataTimer = setInterval(timerMethod, 240000);
//Set an initial timer for the box coloring method
var RefreshBoxTimer  = setInterval(boxMethod, 3000);

Grid data refresh timer handler:

//Every 2.5 minutes this function will reload all of the grid data.
//It also triggers the boxMethod function.
function timerMethod() {
    $("#UpdateStatus_Div").fadeIn(300).delay(1000).fadeOut(300);
    RunStatusGrid.clearAndLoad("data/RunStatus.php");
    CmdlineGrid.clearAndLoad  ("data/CmdlineDataGet.php");
    Results0Grid.clearAndLoad ("data/Results0Data.php");
    Results1Grid.clearAndLoad ("data/Results1Data.php");
    Results2Grid.clearAndLoad ("data/Results2Data.php");
    Results3Grid.clearAndLoad ("data/Results3Data.php");
    RefreshBoxTimer = setInterval(boxMethod, 2500); 
}

Grid data styling timer handler:

//This function searches all of the grids for ERROR/FAIL/SKIP/WARN and changes 
//the cell background colors to clearly show where there are issues.
//It will only run 3 times because it is CPU intensive. The 2.5 second delay is because
//the clearAndLoad functions are run as background tasks and don't complete immediately.
var BoxCounter = 0;
function boxMethod() {
    BoxCounter++;
    if(BoxCounter >= 4) {
        BoxCounter = 0;
        clearInterval(RefreshBoxTimer);
    }

    $("td").each(function(index) {
        if( (this.innerHTML == "ERROR") || (this.innerHTML == "FAIL")) {
            this.style.backgroundColor = "red";
            this.style.fontWeight = "bold";
        } else if ( (this.innerHTML == "SKIP") || (this.innerHTML == "WARN") ) {
            this.style.backgroundColor = "yellow";
            this.style.fontWeight = "bold";
        }
    } );
}

Any help would be greatly appreciated.

  • 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-31T07:04:51+00:00Added an answer on May 31, 2026 at 7:04 am

    Use setTimeout instead of setInterval, and reset the timer each time the callback is invoked.

    The problem with setInterval is that if the computer is too busy doing other stuff the callbacks can end up getting “stacked up”, so they all fire at once.

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

Sidebar

Related Questions

Many applications have grids that display data from a database table one page at
We have a webpage that contains three grids full of data. The grids are
I am using zend. Sometimes I have to show data from database on a
I have a datagrid that I have filled with data from a sql database.
I have a Rad Grid View that I'm using to display some data and
I have a form that consists of two data grids and a button. Datagrid
I have a web page displaying data using dojo datagrid. Sometimes, users need to
I have few grids on a page. After I edit data in them I
I have 2 advanced data grids, one above the other. They both have the
I have a tabbed series of grids on a data preview page. I now

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.