Created
June 18, 2010 01:23
-
-
Save edgargoncalves/443075 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pingTimer = null; | |
var pingServer = function () { | |
//make a background server request to a ping service | |
var x = $("<script/>", {src: "/servlet/ping"}); | |
$("body").append(x); | |
x.remove(); | |
}; | |
var resetPingTimer = function () { | |
if (pingTimer !== null) { | |
clearInterval(pingTimer); | |
} | |
pingTimer = null; | |
pingTimer = setInterval(pingServer, 120000); //2mins | |
}; | |
var ajaxStopHandler = function() { | |
resetPingTimer(); | |
}; | |
$.ajaxStop(ajaxStopHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment