Time increase when offline SetInterval jquery -
i have scenario according when user user online @ every 3 or 4 sec request sent server, problem start when user go offline scenario want increase time of setinterval method of jquery have written code it, no success yet:-
my code this
var interval= function(){ if(hasinternets()){ var inter= 15000; return inter; } else { var inter= 15000; inter+= 15000; return inter; } }; setinterval( function(){ if (hasinternets()) { // here doing } }, interval());
hasinternet method check internet connection.
so if guys can me, in advance.
since function in javascript objects, can assign inter
field object stored between function calls:
var interval = function(inter) { if (!interval.inter) { interval.inter = 15000; } if (hasinternets()) { return interval.inter; } else { interval.inter += 15000; return interval.inter; } }; setinterval(function() { if (hasinternets()) { // here doing } }, interval());
Comments
Post a Comment