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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:57:07+00:00 2026-06-07T17:57:07+00:00

I built a site display messages, so the msgloader.js updates the messages every 10

  • 0

I built a site display messages, so the msgloader.js updates the messages every 10 seconds from admin. The client displays this site on a screen constantly.

The problem is that sometimes the internet connection is not so good, the display got disconnected and the msgloader.js still updates the messages, in the end the screen freeze (the reason I know is that there is a clock on the site as well, the clock gets time from the local machine, it simply freeze at a time until we refresh the page which is an issue).

I suspect this freeze issue is because there is too much script running and the machine ram has been taken up.

BACK TO THE QUESTION, Is there any way we can set the below code into update messages every 10 seconds when there is an internet connection, otherwise update messages every hour/two when there is no internet connection.

Any help is appreciated. Thanks.

--------------------------------------------------------------------
Update the data for the static sections
--------------------------------------------------------------------
*/
function updateSection(sect) 
{   
    setTimeout('updateSection(' + sect + ')', 10000);

    //alert('updateSection: ' + sect);
    var ajax = new sack();
    ajax.requestFile = 'ajax/getMessages.php?section='+sect;
    ajax.method = 'post';
    /*ajax.onError = whenError;*/
    ajax.onCompletion = whenComplete;
    ajax.runAJAX();

/*  function whenError() 
    {
        alert('Could not return getMessages values. <br />Please notify the system administrator.');
    }*/

    function whenComplete() 
    {
        var messages = ajax.response;

        var messages1 = messages.split('---');

        var num_messages    = messages1[0];
        //alert('Num Lines: ' + num_messages );
        var messages_list   = messages1[1];
        //alert('MESSAGES: '+messages);
        var msg_data_array  = messages_list.split('::');

        var i=0;            
        switch(sect)
        {
            case 1:

                for(i=0;i<=num_messages;i++)
                {

                    var j = i + 1;
                    icon_to_use = 'icon'+j;

                    // Set icon class
                    var icon = document.getElementById('icon_' + sect + '_' + j);
                    icon_to_use.className = 'icon_pointer';

                    // Set message text
                    // -------------------------------------------                  
                    var msgtext_array = msg_data_array[i].split('##');


                    // Here's the title
                    // -------------------------------------------
                    var msgtext_1a = msgtext_array[1];


                    // Here's the text
                    // -------------------------------------------
                    var msgtext_1 = msgtext_array[2];

                    // Set the title space
                    // -------------------------------------------
                    var msg_1a = document.getElementById('msg_text_' + sect + '_' + j + 'a');

                    // Set the text space
                    // -------------------------------------------
                    var msg_1 = document.getElementById('msg_text_' + sect + '_' + j);

                    // Write in the title
                    // -------------------------------------------                      
                    msg_1a.innerHTML = msgtext_1a;
                     msg_1.innerHTML = "<img src='[url_of_image]' /> " + msgtext_1;
                    // Write in the text
                    // -------------------------------------------                      
                    msg_1.innerHTML = (msgtext_1) ? separator + msgtext_1 : msgtext_1;

                    //msg_1a.style.borderBottom="2px solid white";
                    msg_1a.style.borderBottom="2px solid white";
                    msg_1.style.borderBottom="2px solid white";

                }   break;
            default:
                break;          
        }

        // DEBUG
        if(debug)
        {
            debugReport
            (
                'updateSection():ID: '+msg_id+
                '<br />'+'updateSection():TIMEOUT: '+timeout+
                '<br />'+'ROTATE: '+rotate
            );
        } 
        else 
        {
            debugReset();
        }
    }
}
/*
  • 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-07T17:57:08+00:00Added an answer on June 7, 2026 at 5:57 pm

    If I’m understanding you correctly you could do something like this:

    every time onerror event happens on an ajax request increment a counter. After a set limit of fails in a row / fails in an amount of time you change the length of the time-out.

    var timeoutLength = 10000
    setTimeout('updateSection(' + sect + ')', timeoutLength);
    

    changing the timeoutLength once the ajax requests are failing, IE there is not internet connection.

    EDIT

    var errorCount = 0;
    
    ajax.onError = whenError;
    
    function whenError() {
      errorCount++
      if(errorCount < 5) {
        timeoutLength = 3600000
      }
    }
    
    
    function whenComplete() {
       errorCount = 0
       ...
    }
    

    This requires 5 errors in a row to assume that the internet is down. You should probably play around with that. But this should show you the general idea.

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

Sidebar

Related Questions

I have already built a site from scratch. It has banning, PM, comments, etc.
This site is built using CakePHP 1.2* I have an element that needs to
I'm using the Repeater control on my site to display data from the database.
OK, Ive built a status feed for this site Im making which shows a
I have a client with a site (built with Kohana framework) which has a
I built a site that uses the $(window).scroll() jQuery event to programmatically animate in
I built a site a long time ago and now I want to place
I built a site about 6 months ago now and designed a menu with
I built a site in HTML/CSS, and everything was to my liking. However, in
I have built a site which requires user to login. Now I have decided

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.