简体   繁体   English

如何每 1 分钟刷新部分页面?

[英]How to refresh part of page every 1min?

I want to refresh my specific div partition on page at every 1min.我想每 1 分钟刷新一次页面上的特定 div 分区。 How can I do that?我怎样才能做到这一点? Here my test structure:这是我的测试结构:

<div id="test">
   //something inside model items like @Model.TotalUpDeviceCount.ToString()
</div>


<script type="text/javascript">
        $(document).ready(function () {
            setInterval(function () {
                refresh();
            }, 60000);
        });

        function refresh() {
            $('#test').modal.refresh();
        }
</script>

there's a little more to it than your suggested code.它比您建议的代码多一点。

you want to show the updated data coming from your controller which requires a complete page refresh.您想显示来自 controller 的更新数据,这需要完整的页面刷新。 you can however retrieve the data from an api controller and update the div with polling.但是,您可以从 api controller 检索数据并使用轮询更新 div。

setTimeout($.get("....", function(data) {
   $("your div").html(data)
});, 1500)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM