[英]Load data on page scroll not working in mobile browsers
我在滾動頁面時從db獲取數據。 該代碼適用於桌面瀏覽器,但不適用於移動瀏覽器。
我嘗試了不同的解決方案,但都是徒勞的。
$(document).ready(function(){
$('body').on('touchmove', onScroll);
$(window).on('scroll', onScroll);
function onScroll(){
var lastID = $('.load-more').attr('lastID');
if(($(window).scrollTop() + window.innerHeight >= document.body.scrollHeight) && (lastID != 0)){
$.ajax({
type:'POST',
url:'getData.php',
data:'Slno='+lastID,
beforeSend:function(){
$('.load-more').show();
},
success:function(html){
$('.load-more').remove();
$('#postList').append(html);
}
});
}
};
});
試試這段代碼:
$(document).ready(function(){
$('body').on('touchmove', onScroll);
$(window).on('scroll', onScroll);
function onScroll(){
var lastID = $('.load-more').attr('lastID');
if ($(window).scrollTop() > $(document).height() - $(window).height() - 100 && (lastID != 0)) {
$.ajax({
type:'POST',
url:'getData.php',
data:'Slno='+lastID,
beforeSend:function(){
$('.load-more').show();
},
success:function(html){
$('.load-more').remove();
$('#postList').append(html);
}
});
}
};
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.