Preload using AJAX
I am trying to preload the entire website with this script:
<script>
$(function() {
$('#body').addClass("none");
$('#load').ajaxStart(functi开发者_如何学运维on() {
$(this).show();
}).ajaxStop(function() {
$(this).hide();
});
$('#body').removeClass("none");
});
</script>
My body has a class "none" which is basically a display:none. The #load is my obvious loading div. It seems like there is an issue it actually running because #load shows the entire time, doesn't actually get rid of itself when its done loading.
Any ideas?
I tested your code and it worked without problems.
ajaxStop only gets called when all ajax requests have returned or been cancelled. One of your requests must therefore be hanging. Another possibility is that the request threw an exception (cross domain for example - see here).
精彩评论