javascript - Variable undefined when waking from sleep in Chrome -
using mac os x 10.8.4, chrome 27 (latest stable).
i have script every x seconds (with setinterval()
) makes ajax call jquery see if there's still connection server (heartbeat). posts data , depending on if succeeded or not, calls other functions.
it works fine until mac goes sleep (screen black, hdd powers down, etc.), wake , ajax call failed , tried call function (variable) apparently no longer exists:
post http://mywebsite.com/index.php jquery.min.js:4 uncaught typeerror: cannot call method 'onlost' of undefined
onlost
function within other variables, such mylib
, anotherlib
. instantiated in loading page. code lot more complex, here's simplified version:
var mylib = new mylib(); mylib.anotherlib = function() { this.onlost = function() { ... }} setinterval() { function() { $.ajax({ failed: mylib.anotherlib.onlost }); }, 10000);
after error occurs, script behaves normal. can access mylib
, onlost()
fine. know browsers implement settimeout()
, setinterval()
when computer sleeps differently (doesn't chrome pause or slow down or something?), it's still odd error.
could way i'm calling failed
or how jquery's $.ajax()
thing?
Comments
Post a Comment