HTML 使用页面一段时间后没有刷新元素丢失

HTML element missing after some time of using page without refresh

我正在 Grails 中制作一个应用程序(在这个应用程序中我使用 AJAX 和 jQuery),我想在更改用户时将微调器放在所有页面的上方。

但是,它在一段时间内(大约 10 分钟)运行良好,并且在使用此页面一段时间后没有刷新微调器不再出现。原因是缺少包含微调器的 HTML 元素。

谁能告诉我为什么会这样?

这里是较短的代码版本:

主页(HTML):

<div class="container">
    <div id="changeUserDiv">
        <g:render template="/changeUser"/>
    </div>

    <div>
        <div id="errorContainer"></div>
        <g:render template="myTemplate"/>
    </div>

    <div id="loadingAllPage" class="modal-background" style="display:none;">
        <i class="fa fa-5x fa-spinner fa-spin"></i>
    </div>
</div>

主页(JS):

$("#changeUserDiv").change(function(){
            $("#loadingAllPage").show();
            ajaxAction();
        });

我的模板(JS):

function ajaxAction()
{
     // some code
     $.ajax({
          // some code
          success:function(data){
              $("#loadingAllPage").hide();
      });
}

首先,这不是显示加载器的正确方式。 您应该检查一些其他方法来清除它。

为此, 问题可能是由于内容在一段时间后发生变化

  1. 其他 ajax 从另一个页面以时间间隔
  2. 调用
  3. div 的内容以其他方式更新