SetInterval仅运行一次

编程入门 行业动态 更新时间:2024-10-28 20:20:40
本文介绍了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仅运行一次

本文发布于:2023-10-29 10:48:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SetInterval

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!