Add timer for updating json

This commit is contained in:
2021-08-09 19:57:36 -04:00
parent 31485b14bb
commit ebca665afa

View File

@ -4,6 +4,18 @@
// Write your JavaScript code. // Write your JavaScript code.
$(function () { $(function () {
if ($("#login_card").length == 0) { if ($("#login_card").length == 0) {
runAjaxTimer();
}
});
$(window).focus(function() {
if ($("#login_card").length == 0) {
runAjax();
}
});
function runAjax() {
if (window.document.hasFocus()) {
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/Index?handler=JsonData", url: "/Index?handler=JsonData",
@ -17,7 +29,13 @@ $(function () {
} }
}); });
} }
}); }
function runAjaxTimer() {
runAjax();
setTimeout(runAjaxTimer, 150000);
}
$("#json_data").change(function () { $("#json_data").change(function () {
var jsonData = JSON.parse($("#json_data").val()); var jsonData = JSON.parse($("#json_data").val());