我所做的就是将不同的内容加载到一个div中。我用来这样做的代码:
$(function(){
$('#galleries').hide().load("letters/index.php", function(){
$(this).slideDown(1);
$(this).slideUp(1);
$(this).hide();
$(this).slideDown(1500);/* or fadeIn() or any other effect*/
document.getElementById("data").style.display = 'none';
});
});这是一个代码的例子。我还有8个这样的页面,但我每次都会加载一个不同的php页面到#画廊中。
我的问题是,加载第二个页面需要很长时间。例如,当我第一次点击任何按钮时,它需要一秒钟的时间来加载所有内容,而不管它有什么内容。但是每当我按下另一个按钮来加载另一个页面时,我必须等待大约3-5秒,当我等待的时候,它什么也没有显示,没有div显示,只有背景。
有没有可能解决这个问题?或者,是否可以插入一个正在加载的图像或文本,让用户知道它正在加载?因此,当页面正在加载时,用户会看到:“正在加载..”或者是一些加载图标。
发布于 2013-01-18 03:55:10
这应该会让你朝着正确的方向前进。
此外,我也不知道你对$(this)的所有不同效果是什么。
$(function(){
$(".loading-image").show();
$('#galleries').hide().load("letters/index.php", function(){
$(this).slideDown(1);
$(this).slideUp(1);
$(this).hide();
$(this).slideDown(1500);/* or fadeIn() or any other effect*/
$("#data").hide(); //replacing your getElementById
$(".loading-image").hide();
});
});https://stackoverflow.com/questions/14386963
复制相似问题