jquery - JavaScript setTimeout() delay -
i encountering problem delay of window.settimeout() seems ignored or randomized.
function timer() { var refreshtimer = 0; var delay = 300000; // 5 min this.init = function () { this.startrefreshtimer(); $(document) .ajaxstop(this.startrefreshtimer) .ajaxstart(this.stoprefreshtimer) ; }; this.startrefreshtimer = function() { refreshtimer = window.settimeout(resettimer, delay - 10000); }; this.stoprefreshtimer = function() { window.cleartimeout(refreshtimer); }; function resettimer() { $.ajax(url); } this.init(); } this works random set of times (and in multiple browsers , tabs) after while delay breaks out.
here's log of request times:
17:50:04 17:54:55 // + 5 min - ~10 sec 17:59:46 // || 18:04:37 // || 18:09:28 // || 18:14:19 // || 18:19:10 // || 18:24:01 // || 18:28:52 // || 18:33:43 // || 18:38:34 // || 18:43:25 // || 18:48:16 // || 18:53:07 // || 18:57:58 // || 19:15:09 // + ~ 17 min ??? i cannot use window.setinterval() , not give more information purspose of code. want know if has made similar experiences and/or knows of solution problem.
Comments
Post a Comment