0
我正在运行一个脚本,它从ajax请求中加载图像和数据,然后将其显示在我的Blocksit图库(一个用于masonary图库的jquery插件)中。问题divs是在图像实际加载之前创建的,因此它们不能正确放置在图库上。我需要以某种方式保存数据,加载它,然后运行该功能以显示画廊。我曾尝试使用setTimout,但显然没有运气。这里是我的代码:在ajax请求上预加载图像
("#loadMore").click(function(){
$.ajax({
url: "loadMore.php",
data: {count: count,
type: type},
type: "POST",
success: function(html){
var data = jQuery.parseJSON(html);
if (data.html == "stop"){
}
else{
setTimeout(function() {
$('#container').append(data.html);
$('#container').BlocksIt({
numOfCol: 3,
offsetX: 5,
offsetY: 5
});
}, 2000);
$('html, body').animate({ scrollTop: $(document).height()-$(window).height() }, 500, "linear");
count = $(".grid").length;
}
}
});
});
任何帮助是极大的赞赏:)
在这种情况下..什么是我的src = to。 我有data.html我正在加载 – diskrim
你必须使用'$('img')来提取出它们each(function(){$(this).attr('src');})' –
所以,我需要首先收集data.html,然后运行.each,然后在加载每个图像时加载数据...可以告诉我如何使其适应我的代码。我搞不清楚了。我在哪里运行这个每个语句。它是否知道从data.html中提取没有说明它? – diskrim