1. problem:
when multiple items are displayed on a single page, pagination is involved, and multiple pages are required. However, as the Internet is changing, waterfall flow occurs, I have not studied it carefully. My personal understanding is that, while the scroll bar is always pulled down, the data is always filled into the region until the request data is complete or the expected end.
the requirement is based on the function. As a result, the product change request is changed to a waterfall stream by page. If you have not studied the waterfall flow, you can imagine that you have done so, one night and one morning.
2. idea:
. set a page to pull 10 pieces of data. When the scroll bar pulls the data to the bottom, it asynchronously pulls the data from the background. After the pull is successful, the existing data on the current page is merged to fill in the current page.
B. action involved: When the page is displayed, the first page is displayed. When the scroll bar is pulled to a certain extent, the second page of data is requested asynchronously. After the data is returned in the background, the page is filled ......
C. data must be displayed in an orderly manner and pulled when it is rolled to a certain extent to ensure that the pulled data is not repeated or missing.
in fact, the key issue is when the page number increases progressively, make sure that the data is pulled.
(Function (NS) {// judge the scroll bar position var scroll = {isend: false, curpage: 1, totalpage: 1, iscroll: function () {// get something here return clientheight + scrolltop> = scrollheight-400; // 400 is the experience value} // callback function for data pulling success getdatasuccess (data) {// do something here scroll. totalpage = data. itotalpage; If (data. ipageindex> = data. itotalpage) {scroll. isend = true ;}}; // function getcurpagedatabyajax (curpage, getdatasuccess) {// do something here}; // listens to the Window Rolling event addevent (global, 'scroll', function () {If (scroll. iscroll () & scroll. isend) {scroll. curpage ++; If (scroll. curpage> scroll. totalpage) {scroll. isend = false; scroll. totalpage = 1;} else {getcurpagedatabyajax (scroll. curpage, getdatasuccess) ;}}); // pull the data at the beginning. getcurpagedatabyajax (1, getdatasuccess);}) (window );