jquery滑动加载下一页
<div class="orderList-content"> <panel id="allOrderList"></panel> </div> var num = 1; var flag = 0; $(document).ready(function () { var $div = $('#allOrderList'); var $window = $('.orderList-content'); var debounceTimeout; // 防抖,跳页问题处理 $window.scroll(function () { clearTimeout(debounceTimeout); debounceTimeout = setTimeout(function () { if ($window.scrollTop() + $window.height() >= $div.offset().top + $div.outerHeight()) { // 在这里添加您的代码 num++; if (flag == 0) { GetData(); } } }, 200); }); }); function GetData() { var index = layer.load(1); //layui的loading,需要自行引用js flag = 1; $.post("myorder.aspx", { action: "GetData", page: num, type: curType }, function (data) { if (data.code == "200") { if (num == 1) { $("#allOrderList").html(data.jsondata); } else { $("#allOrderList").append(data.jsondata); } flag = 0; } else { if (num != 1) { $("#allOrderList").append("<div style=\"text-align:center;margin: 10px 0px;\" class=\"gdxs\">已经到底了 </div>"); } else { $("#allOrderList").html("<div style=\"text-align:center;margin: 10px 0px;\" class=\"gdxs\">已经到底了 </div>"); } flag = 1; } }, "JSON") layer.close(index); }
本文来自博客园,作者:WantRemake,转载请注明原文链接:https://www.cnblogs.com/SmallChen/p/17912991.html