我遇到无限滚动问题。当我向下滚动时,它会加载下一个项目,但它会继续发送这些项目。我一直在使用这个jQuery来给它一个唯一的ID,因为我已经用一个算法对mysql的项目进行了排序:
$("#image-list li").each(function(index) {
$(this).attr('id', index);
});并且为了标记来自外部php文件的新给定项目,我也必须在文件中使用这个代码。
要发送关于给定项目的信息,我一直在使用这个jQuery:
function last_db_item_function()
{
var ID=$(".db-item:last").attr("id");
$('div#last-db-item-loader').html('');
$.post("index.php?action=get&last_db_item="+ID,
function(data){
if (data != "") {
$(".db-item:last").after(data);
}
$('div#last-db-item-loader').empty();
});
};
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
last_db_item_function();
}
});但问题是,它似乎并没有工作。我的意思是它不会从最新解析的php文件中收集最后一个项目标识。解析php我一直在这样做:
$last_db_item = $_GET['last_db_item'];
$action = $_GET['action'];
if($action != "get")
{
.... Code Here....
}else{
include ('secondimages.php');
}所以我的问题是,为什么这似乎永远持续下去?