//当滚动到屏幕最下面触发 $(window).scroll(function () { var windowScrollY = window.scrollY; // 当前滚动条top值 var windowInnerH = window.innerHeight; // 设备窗口的高度 var bodyScrollH = document.body.scrollHeight; // body总高度 if (windowScrollY + windowInnerH == bodyScrollH) { //页数+1 pageIndex++; //如果当前页数大于总页数 if (pageIndex > totalPage) { console.log("加载完成"); } else { init(pageIndex, 10); } } });
}); </script>
submit_ajax.ashx添加getList
1 2 3 4 5 6 7 8 9
publicvoidgetList(HttpContext context) { int page_size = DTRequest.GetQueryInt("page_size"); int page_index = DTRequest.GetQueryInt("page_index"); DataTable dt = new BLL.course().GetList(page_index, page_size); string json = SerializationHelper.ToJsonString(dt); context.Response.Write(json); }
bll层代码
1 2 3 4
public DataTable GetList(int category_id, int page_index, int page_size) { return dal.GetList(category_id, page_index, page_size); }
dal层代码
1 2 3 4 5 6
public DataTable GetList(int category_id, int page_index, int page_size) { string sql = ""; sql = string.Format("select * from 表名 order by id offset(({1} - 1) * {2}) rows fetch next {2} rows only", page_index, page_size); return DbHelperSQL.Query(sql).Tables[0]; }