使用setInterval刷新div但会干扰页面模板

问题描述 投票:0回答:1

您好,我正在尝试刷新我的MVC视图页面,该页面使用以下代码显示来自数据库的数据

<div id="stuDetails" class="col-md-6 col-xs-12">
                <div id="AttendanceStatus" class="ts-intro">
                    <h2 class="into-sub-title">Live Attendance</h2>
                    <h3 class="into-title">&#40;@DateTime.Now&#41;</h3>

                    <table class="mu-blog-caption table">
                        @foreach (DataRow row in Model.Tables[0].Rows)
                        {
                            <tr style="background-color:#30652c; color:#fff;">

                                <td>
                                    No. of person present in Hotel
                                </td>
                                <td>
                                    &#58;&nbsp;@row["No_of_persons_Inn"]


                                </td>
                            </tr>
                            <tr style="background-color:#B73522; color:#fff;">
                                <td>
                                    No. of person out of the in Hotel
                                </td>
                                <td>
                                    &#58;&nbsp;@row["No_of_persons_Out"]


                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Total 
                                </td>
                                <td>
                                    &#58;&nbsp;@row["Total_persons"]

                                </td>
                            </tr>

                                <tr>
                                    <td><label id="lblmessage"></label> </td>
                                    <td>
                                        <p>   <a class="btn btn-default" href="#">Absent list &raquo;</a></p>
                                    </td>

                                </tr>
                        }
                    </table>

                </div>
<script type="text/javascript">
    $(document).ready(function () {

        setInterval("refresh();", 1000);
    });
    function refresh() {
                $("#AttendanceStatus").load("#AttendanceStatus");
</script>

尽管它刷新页面并显示所需的结果,但它干扰了模板并在要刷新的页面中显示整个页面,但我得到的结果如屏幕截图所示。enter image description here

javascript .net model-view-controller jscript
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.