如何在https://www.seznam.cz/中获取卷轴?
这是我的代码,它可以工作,但它在底部添加数据。我想将数据500像素添加到底部?
var flag= 5;
$(window).scroll(function(){
var heigh_scroll= $(window).scrollTop();
if( heigh_scroll == $(document).height() - $(window).height() ){
// console.log('ajax');
jQuery.ajax({
url:'site/ajax-bottom',
type: 'POST',
data: {
'offset':flag,
'limit':1,
},
success: function (data) {
$('.timeline__list').append(data);
flag+=5;
},
error: function (xhr, textStatus, errorThrown) {
//errorPosition();
jQuery('.restult').html('Please enter again');
console.log('Error' );
}
});
}
});发布于 2017-09-28 20:12:56
var callAPI = true;
$(window).scroll(function () {
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
alert('end of page');
//----call your function here ---
if(callAPI){ funCallAPI(); }
}
});
function funCallAPI(){
callAPI = false;
....
...
ajax_success_response:{
callAPI = true;
}
}-10指示在函数执行之前用户必须离页末多远。这使您可以根据需要灵活地调整行为。
check this example
注意:ajax_success_response将是真正的$.ajax函数。
https://stackoverflow.com/questions/46468726
复制相似问题