页面下拉加载更多数据(spring MVC)
程序员文章站
2022-07-12 19:36:10
...
var SEE_MORE={p:1,loading:false,hasData:true}; //下拉到底 js 判断 $(window).scroll(function () { loadData(); }); function loadData() { totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); if ($(document).height() <= totalheight +300) { //下啦加载时运行 loadmore(); } } <%//加载更多 %> function loadmore(){ if(!SEE_MORE.loading&&SEE_MORE.hasData){ SEE_MORE.loading = true; var path='${ctx}/liveClass/listMore'; $.post(path+'?size=6&pageNum='+SEE_MORE.p,function(data){ if($.trim(data)!=''){ $('#courseContainer').append(data); SEE_MORE.p++; } SEE_MORE.loading = false; },'html'); } };
<!-- 隐藏域 获取 页数, 总数/pageSize --> <input type="hidden" value="${liveClassListCount/6 }" id="pageNumberId"> <div class="container"> <ul class="live_list" id="courseContainer"> <%@include file="live_list_more.jsp"%> </ul> </div>
live_list_more.jsp 和正常jsp一样 获取后台绑定的参数就行