0

I need to run this function every time its work if the tab is active but in inactive tab javascript is very slow (i use chrome)

function request() {
   $.ajax({
        type: "GET",
        encoding:"UTF-8",
        url: 'request.php',
        success: function(data) {
           request();
        }
   });
}

what is solution for this problem ? I have already tested with setInterval()

Thanks you

Miky
  • 109
  • 2
  • 10
  • 1
    I recently had a problem like this, intervals don't work very fast when Chrome is not in focus. You can use a web worker instead. Also, this is a possible duplicate of [this question](http://stackoverflow.com/questions/5927284/how-can-i-make-setinterval-also-work-when-a-tab-is-inactive-in-chrome/5927432#12522580) – Ben Aubin Oct 05 '15 at 22:47
  • Have you tried other browsers? Most likely Chrome is throttling that tab and making it run more slowly. – Adam Mazzarella Oct 05 '15 at 22:48
  • Thanks for reply u have an example with ajax request @penne12 ? For other browsers its work only with IE – Miky Oct 05 '15 at 23:10
  • Yeah look at the question I linked. – Ben Aubin Oct 05 '15 at 23:11
  • You speak about WebWorkers Code ? Because `stop(true,true)` not work and my function is not an animation just an ajax request – Miky Oct 06 '15 at 00:10

0 Answers0