Last active
December 14, 2015 12:39
-
-
Save sudoyu/5087658 to your computer and use it in GitHub Desktop.
JustGage http://www.justgage.com/ を使って定期的に .refresh() するメモ。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JustGageの対象要素に対して描画 | |
var g = new JustGage({ | |
id: "gauge", | |
value: 0, | |
min: 0, | |
max: 10, | |
title: "counter" | |
}); | |
// ajaxリクエストでrefresh()する関数 | |
function getGauge() { | |
$.ajax({ | |
url : "/count/get/", | |
dataType : "text", | |
success : function(data){ | |
g.refresh(data); | |
} | |
}); | |
}; | |
// jQuery で定期的に実行 | |
$(function() { | |
var timer = setInterval( function () { | |
getGauge(); | |
} , 1000 ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment