<script>
$(function(){
var i = 0 ;
$(window).scroll(function(){
// 当滚动到最底部以上50像素时, 加载新内容
if ($(document).height() - $(this).scrollTop() - $(this).height()<270){
var myDate = new Date();
row = $('.rooms_show_ul').children('li').last().attr('data-row');
if(i != row){
jQuery.ajax({url:'/index.php',
type: 'GET',
data:{act:'ajaxForHouses',row:row,date:myDate},
dataType: 'html',
timeout: 1000,
async : true,
error: function(){
},
success: function(result){
$('.rooms_show_ul').append(result);
}
});
i = row;
}
}
});
});
</script>
$(function(){
var i = 0 ;
$(window).scroll(function(){
// 当滚动到最底部以上50像素时, 加载新内容
if ($(document).height() - $(this).scrollTop() - $(this).height()<270){
var myDate = new Date();
row = $('.rooms_show_ul').children('li').last().attr('data-row');
if(i != row){
jQuery.ajax({url:'/index.php',
type: 'GET',
data:{act:'ajaxForHouses',row:row,date:myDate},
dataType: 'html',
timeout: 1000,
async : true,
error: function(){
},
success: function(result){
$('.rooms_show_ul').append(result);
}
});
i = row;
}
}
});
});
</script>

本文介绍了一种使用JavaScript实现无限滚动加载新内容的方法,当用户滚动到页面底部时,自动加载更多数据并更新显示。

468

被折叠的 条评论
为什么被折叠?



