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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:09:34+00:00 2026-05-29T09:09:34+00:00

I have the code as per below. This retrieves some data to use for

  • 0

I have the code as per below. This retrieves some data to use for the counter including a variable for the reload interval – this is NOT used below in order to rule out an issue with the data retrieval, I have hard coded a 10 second interval instead but the problem remains.

All works fine for the intial page load and also for one interval, then everything goes haywire, the calls are made with no delay and the counter cannot react before the next call is made, both the onAnimationStopped and the setInterval appear to be ignored eventually leading to a total hang.

There is some sort of a loop happening somewhere but despite trawling for a few hours none of the answers I have found related to setInterval/Ajax calls answer this issue.

Please note I have also tried setTimeout but this exhibits identical behaviour.

Any help appreciated.

(Only tested using FF and Chrome at present – same issue in both).

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.easing.1.3.js" type="text/javascript"></script>
<script src="js/jquery.flipCounter.1.2.js" type="text/javascript"></script>
</head>
<body>  
<div id="counter">
<input type="hidden" name="counter-value" value="0" />
</div> 
<script type="text/javascript">
    /* <![CDATA[ */
            jQuery(document).ready(doAjax());

                    function doAjax()
                    {   
                        jQuery.ajax({
                            async: false,
                            type: "POST",
                            url: "counterData.php",
                            dataType: "json",
                            cache: false,
                            success: function (data){
                                doTheCounter(data);
                                }
                        })
                    }

                    function doTheCounter(data)
                    {   

                        var scrollfromnumber = data.scrollfromnumber;
                        var displaynumber = data.displaynumber;
                        var reloadinterval = data.reloadinterval;

                        jQuery("#counter").flipCounter({
                            number: scrollfromnumber,
                            numIntegralDigits:6,
                            numFractionalDigits:0
                        });

                        jQuery("#counter").flipCounter("startAnimation", {
                            end_number: (displaynumber),
                            easing:jQuery.easing.easeInOutCubic,
                            duration:5000,
                            onAnimationStopped: function(){
                                setInterval(doAjax,10000);
                                }
                        });
                    }
        /* ]]> */
</script>
</body>
</html>
  • 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-29T09:09:35+00:00Added an answer on May 29, 2026 at 9:09 am

    Do not send ajax requests or start animations with a setInterval, setInterval doesn’t allow for slow browsers/networks or network connection failures. Use setTimeout instead.

    Also, $(document).ready(doAjax()); should be $(document).ready(doAjax);

    jQuery(document).ready(doAjax);
    
    function doAjax() {
        jQuery.ajax({
            async: false,
            type: "POST",
            url: "counterData.php",
            dataType: "json",
            cache: false,
            success: function(data) {
                doTheCounter(data);
            }
        })
    }
    
    function doTheCounter(data) {
    
        var scrollfromnumber = data.scrollfromnumber;
        var displaynumber = data.displaynumber;
        var reloadinterval = data.reloadinterval;
    
        jQuery("#counter").flipCounter({
            number: scrollfromnumber,
            numIntegralDigits: 6,
            numFractionalDigits: 0
        });
    
        jQuery("#counter").flipCounter("startAnimation", {
            end_number: (displaynumber),
            easing: jQuery.easing.easeInOutCubic,
            duration: 5000,
            onAnimationStopped: function() {
                setTimeout(doAjax,10000);
            }
        });
    }
    

    The reason your code fails with setInterval is because you never cleared the previous interval, you just started another one every time, so first you sent one request, then 2, 4, 8, 16, 32, 64, etc. until the browser crashes.

    UPDATE:

    jQuery(document).ready(doAjax);
    
    jQuery(document).ready(function(){
        jQuery("#counter").flipCounter({
            number: 0,
            numIntegralDigits: 6,
            numFractionalDigits: 0
        });
    });   
    
    function doAjax() {
        jQuery.ajax({
            type: "POST",
            url: "counterData.php",
            dataType: "json",
            cache: false,
            success: function(data) {
                doTheCounter(data);
            }
        })
    }
    
    function doTheCounter(data) {
    
        var scrollfromnumber = data.scrollfromnumber;
        var displaynumber = data.displaynumber;
        var reloadinterval = data.reloadinterval;
    
        jQuery("#counter").flipCounter("startAnimation", {
            end_number: (displaynumber),
            easing: jQuery.easing.easeInOutCubic,
            duration: 5000,
            onAnimationStopped: function() {
                setTimeout(doAjax,10000);
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code similar to this filtering entries in an Array of Objects: var
I have code like this: var newMsg = new Msg { Var1 = var1,
I have code like this: template <typename T, typename U> struct MyStruct { T
I have code like this to move the player in my game left, right,
I am using Moq as my mocking framework. As per the code below, I
I have a variable with hyper links (www.wow.com) like this. I have to pass
I have some code (that is working), but I just want to make sure
i have a mysql table structured as per the example below: POSTAL_CODE_ID|PostalCode|City|Province|ProvinceCode|CityType|Latitude|Longitude 7|A0N 2J0|Ramea|Newfoundland|NL|D|48.625599999999999|-58.9758
I have a piece of code that imports data into a sql table. When
I have an XML file that is bound to a listbox as below. This

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.