其实我是想做类似计算在线时间,每秒都在做function,但是到了累积到一定的时限会重新计算过...
但是我不要refresh browser了就重新开始计算过...
所以我想把totalOnlinePerSecond放在一个database或着txt里...
**PS: 我没接触过Ajax
- <script>
- var defaultValue = 5; //当重新开始计算的时候会在哪里开始
- var plus = 1;
- var max = 100;
- var total = defaultValue;
-
- window.setInterval(
- function () {
-
- if (total > max){ //if max total will re-looping
-
- total = defaultValue;
- }
-
- document.getElementById("demo1").innerHTML = total; // display in html
- total = total + plus;
- }, 1000);//run per second
-
- </script>