Try this solution, as Alex mentions, there is no need to write it inside the document. As you do not do any manipulations with the DOM.
setInterval(function(){
imStillAlive();
}, 6000);
function imStillAlive() {
jQuery.post('/users/update_useractive',
function(data){
alert("updated");
});
}
source
share