简体   繁体   English

强制重新加载使用 AJAX 刷新内容的整个页面

[英]Force Reload Entire Page That Uses AJAX to Refresh Content

I have a page that refreshes a div content using jQuery AJAX every 10 seconds.我有一个页面使用 jQuery AJAX 每 10 秒刷新一次 div 内容。

I want to pass a script with the same content retrieved with AJAX to force the entire page to reload whenever I make changes to some CSS/JS of that page.我想传递一个与 AJAX 检索到的内容相同的脚本,以在我对该页面的某些 CSS/JS 进行更改时强制重新加载整个页面。

The page is open all day at the office to 40 agents.该页面在办公室全天向 40 位代理开放。 I don't want to tell them every time to reload the page.我不想每次都告诉他们重新加载页面。

success: function (data) {

    $container.append(data);

}

How to safely pass executable JS or a refresh meta tag with data如何安全地传递可执行 JS 或带有data的刷新元标记

You can use below JS function to reload div:您可以使用下面的 JS function 重新加载 div:

<div id='data'></div>

In JS:在 JS 中:

setTimeout(function () { CallAjax() }, 2000);

CallAjax Function: CallAjax Function:

$.ajax({
        type: 'get',
        dataType: 'json',
        async: true,
        url: 'url',
        data: {  },
        success: function (data) {
            $("#data").html(data);
        },
        error: function () {

        }
    });

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

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