Applying timer in MVC Application which updates db on regular intervals. The below timer is not applying at application level because the script is being applied to only specific pages in application but not to the whole application. Is there any way I can apply timer at application level and update db at regular intervals
$(function () {
LastActivityTimer();
var active ;
var LoggerTimer = '';
function LastActivityTimer() {
$.getJSON('/Account/ActivityTimer/').done(function (value) {
LoggerTimer = parseInt(value);
active = setInterval(SaveLastActiveTime, LoggerTimer);
});
}
function SaveLastActiveTime() {
$.ajax({
type: "POST",
url: '/Account/SaveLastActiveTime/',
cache: false,
//data: { userId: data.userId },
dataType: "json"
});
}
}
});