页面向下滚动ajax获取数据的实现方法(兼容手机)
页面向下滚动ajax获取数据的实现方法(兼容手机)
$(window).scroll(function () { var scrollTop = $(this).scrollTop(); var scrollHeight = $(document).height(); var windowHeight = $(this).height(); if (scrollTop + windowHeight >= scrollHeight) { loadPromotions(); } }); var page = 1; var morAvaliable = true;//标识还有数据可以加载 function loadPromotions() { if (morAvaliable) { var href = location.href.split('?')[0]; var pageSize = 5; page++; $.post(href, { pageNo: page, pageSize: pageSize } , function (data) { if (data.length) { var html = ''; $.each(data, function (i, list) { html += '<div class="task-time">' + list.CreateTime + '</div>'; html += '<a class="task-box" href="' + list.Url + '">'; html += '<h5>' + list.Title + '</h5>'; }); $('#promotionList').append(html); } else { morAvaliable = false; $('#loading').html('没有更多分享信息了'); } } ); } }
相关推荐
wikiwater 2020-10-27
jczwilliam 2020-08-16
littleFatty 2020-08-16
Aveiox 2020-06-23
阿斌Elements 2020-06-11
zrtlin 2020-11-09
xuebingnan 2020-11-05
heheeheh 2020-10-19
Crazyshark 2020-09-15
softwear 2020-08-21
ZGCdemo 2020-08-16
idning 2020-08-03
jinxiutong 2020-07-26
lanzhusiyu 2020-07-19
Skyline 2020-07-04
xiaofanguan 2020-06-25