本文介绍了SetInterval仅运行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的JavaScript代码:
This is my JavaScript code:
<script src="code.jquery/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仅运行一次
发布评论