SetInterval仅运行一次 [英] SetInterval only runs once
本文介绍了SetInterval仅运行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的JavaScript代码:
This is my JavaScript code:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function mytest() {
var jqxhr = $.get("Home/GetMonitorData", function (data) {
$("#cpu").text(data.cpu);
$("#dspace").text(data.dspace);
$("#cspace").text(data.cspace);
$("#pf").text(data.pf);
$("#totphysical").text(data.totphysical);
$("#freephysical").text(data.freephysical);
$("#tcp").text(data.tcp);
$("#req").text(data.req);
}, "json");
}
$(document).ready(function () {
setInterval(mytest, 3000);
});
</script>
问题是,setInterval仅运行一次.我的程序应该从一种操作方法中获取一些WMI信息,在屏幕上打印出来,并每3秒刷新一次这些值.但是刷新一次后,它停止了.有任何建议/想法吗?
The issue is, setInterval only runs once. My program is supposed to get some WMI Information from an action method, print in on screen, and refresh these values every 3 seconds. But after one refresh, it stops. Any suggestions/ideas?
推荐答案
调用ajax时需要设置Request.Expires = 0
.
You need to set Request.Expires = 0
when calling ajax.
这篇关于SetInterval仅运行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文