我有一个网站在 window.location.hash 更改事件上动态加载内容,我有一个非常烦人的问题,我似乎无法解决。本质上在 body div 中有 2 个 div;一个 id 为“loader-container”,另一个是 $mainContent 所以
<body>
<div id=loader-container></div>
<div $mainContent></div>
</body>
在 $mainContent 中加载新页面时,我希望在“loader-container”中显示一个旋转加载 gif。问题是我无法让加载器容器加载内容,但是 $mainContent 的数据确实加载了。这是js:
$(window).bind('hashchange', function(){
alert("This is being called");
$('#loader-container').load('loading.php'); //this works here
newHash = window.location.hash.substring(1);
if (newHash.substring(1,26) == "content/event.php?event_id"){
$('#loader-container').load('loading.php'); //this doesnt work but the below code is being called inside the if statement
$mainContent.slideUp("slow", function() {
alert("This isnt being called!");
alert("Below, loading.php isn't being loaded but newHash is");
$('#loader-container').load('loading.php', function(){
$mainContent.load(newHash, function() { //this load's newHash successfully
$mainContent.show('slow', function() {
$pageWrap.animate({
height: baseHeight + $mainContent.height() + "px"
});
alert("this isn't being called");
});
alert("or this");
});
alert("or this");
});
$("#loader-container").hide();
});
}
});