Add timer for updating json
This commit is contained in:
@ -4,6 +4,18 @@
|
||||
// Write your JavaScript code.
|
||||
$(function () {
|
||||
if ($("#login_card").length == 0) {
|
||||
runAjaxTimer();
|
||||
}
|
||||
});
|
||||
|
||||
$(window).focus(function() {
|
||||
if ($("#login_card").length == 0) {
|
||||
runAjax();
|
||||
}
|
||||
});
|
||||
|
||||
function runAjax() {
|
||||
if (window.document.hasFocus()) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/Index?handler=JsonData",
|
||||
@ -17,7 +29,13 @@ $(function () {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function runAjaxTimer() {
|
||||
runAjax();
|
||||
setTimeout(runAjaxTimer, 150000);
|
||||
}
|
||||
|
||||
|
||||
$("#json_data").change(function () {
|
||||
var jsonData = JSON.parse($("#json_data").val());
|
||||
|
||||
Reference in New Issue
Block a user