我正在使用AJAX功能來實時加載我的WordPress頁面。我用下面的辦法,使其在實時負載AJAX加載程序不會保留,直到加載新內容
var toLoad = $(this).attr('href')+' #container';
$('#container').slideUp('300',loadContent);
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#container').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#container').slideDown('400',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
我面臨的問題是,加載...文本顯示半秒和舊的內容再次出現..然後經過4-5秒,它只是替換舊的內容。 如何在內容完全加載之前保留加載文本。
問題解決:) 這正是我一直在尋找。 非常感謝 – 2012-07-10 06:55:13