how to hide spinner after the content loads

有些话、适合烂在心里 提交于 2021-01-29 11:15:56

问题


I'm using pjax to load content and while the content is loading, I show a spinner:

$('a[data-pjax]').pjax().live ("click", function () {
    $("#loader").show();
});

This works fine, however, after the content loads the loader still stays there.

Where should I call $(#loader).hide() to hide the loader after the content has loaded?


回答1:


According to the doc https://github.com/defunkt/jquery-pjax

$(document).on('pjax:complete', function() {
  $("#loader").hide()
})

I think you can also use pjax:end event.




回答2:


of course after the content loads, after your ajax call within the success function.

$.ajax({
          url: "test.html",
          data: {parameter:parameter},
          }).done(function() {
               //on return, add here
               $("#loader").hide()
          });


来源:https://stackoverflow.com/questions/18152925/how-to-hide-spinner-after-the-content-loads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!