Add timer for updating json
This commit is contained in:
@ -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());
|
||||||
|
|||||||
Reference in New Issue
Block a user