Fundamentals of Scrolling data:
Loads the next page of data when the scroll height and the visible height are greater than or equal to the content height.
As in the following example, a div with the class name Result_con appears as a scroll bar:
var currentpage = 1;//Current page var maxPage = 10;//Total Pages
//Scrolling Load Data$ (". Result_con"). On ("scroll",function () { varVIEWH = $ ( This). Height ();//Visible Height varContenth = $ ( This). Get (0). scrollheight;//Content Height varScrollTop = $ ( This). ScrollTop ();//scrolling Height //Console.info (VIEWH); //Console.info (contenth); //Console.info (scrolltop); if(VIEWH + scrolltop >= contenth && currentpage <maxPage) {CurrentPage++; //perform functions that load data }})
If the scroll bar appears in document, the
//Scrolling Load Data$ (document). ON ("scroll",function () { varVIEWH = Document.body.clientHeight;//Visible Height varContenth = Document.body.scrollHeight;//Content Height varScrollTop = $ ( This). ScrollTop ();//scrolling Height //Console.info (VIEWH); //Console.info (contenth); //Console.info (scrolltop); if(VIEWH + scrolltop >= contenth && currentpage <maxPage) {CurrentPage++; //perform functions that load data }})
Scrolling load data