我在一个页面中有多个div,其内容通过ajax加载。我想显示一个加载gif,它会执行以下操作,基本上ajax_load_comments和pics是带有动画gif背景的div(分别在注释和pics容器中),显示在ajaxStart上并隐藏在ajacstop上。multiple div ajax加载
问题是无论哪个容器正在更新,它们都显示出来。我如何将它们绑定到特定容器的ajaxStart?我喜欢在主js文件中进行一次绑定,而不是在不同的页面中进行多次绑定。
$("#ajax_load_pics, #ajax_load_comments").bind("ajaxStart", function(){
$(this).fadeIn('slow');
$(this).parent().animate({
opacity: 0.3
}, 'slow', function() {
// Animation complete.
});
}).bind("ajaxStop", function(){
$(this).fadeOut('slow');
$(this).parent().animate({
opacity: 1
}, 'slow', function() {
// Animation complete.
});
});
好的,这里是我现在正在做的,但我真的看不到加载div。
$('.pagination a').live("click", function() {
showLoad($(this).parent());
/* $.get(this.href, null, function (data) {
$('#com_prog_loading').fadeOut('slow');
elem.remove($('#com_prog_loading'));
}, 'script');*/
$.get(this.href, null, null, 'script');
return false;
});
function showLoad(elem) {
elem.parent().prepend("<div id='com_prog_loading'></div>");
$('#com_prog_loading').fadeIn('slow');
}
function hideLoad() {
}
你在哪里加载内容在? – 2010-07-10 21:53:06
内容通过事件绑定进行加载,以便在不同元素上完成ajax调用,其中一些也基于setInterval。 FE =>当某人通过评论进行分页或在页面加载后用图片填充图片内容等 – badnaam 2010-07-10 21:55:56
@badnaam - 你可以绑定到这些相同的事件吗? – 2010-07-10 22:12:55