1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

jQuery and setTimeout stops working on Internet Explorer 11

Discussion in 'jQuery' started by xms, May 4, 2017.

  1. #1
    I have some jQuery code which will be executed every 6 seconds.

    With Mozilla Firefox 51.0.1 it works fine. With Internet Explorer 11 it seems to be working just fine, but when I leave my computer, do something else, and come back, it is possible that Internet Explorer 11 has stopped running the script. For example, after several hours. In other words, it will not be executed every 6 seconds anymore. There are no error messages available.
    SEMrush
    How could I solve the problem?

    <script src="/jquery-3.0.0.min.js"></script>
    
    <script type="text/javascript">
    <!--
    
    $(document).ready(function(){
    
      valvonta = function() {
        var kaavio = 106; // 38;
    
        var a = performance.now();
    
        jQuery.post("hae_tilanteet.php", {
          kaavio: kaavio
        }).done(function(data) {
          var b = performance.now();
    
          $('#valvonta').html(data);
    
          var c = performance.now();
    
          // alert('search ' + (((b - a)/1000)%60) + ' s and update ' + (((c - b)/1000)%60) + ' s');
    
          setTimeout(valvonta, 6000);
        });
      };
    
      setTimeout(valvonta, 6000);
    
    });
    
    //-->
    </script>
    Code (JavaScript):
     
    xms, May 4, 2017 IP
    SEMrush
  2. xms

    xms Active Member

    Messages:
    169
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    I guess that my problem has something to do with this issue:

    http://stackoverflow.com/questions/6032429/chrome-timeouts-interval-suspended-in-background-tabs?noredirect=1&lq=1

    So, how could I modify my original code?
     
    xms, May 4, 2017 IP