Import Jquery.mousewheel.js
Defining url= Paths
Js
1$(function(){2 /*3 * Sliding loading4 * */5 varpage = 1;6 varend = 0;//1 means all loaded .7 varplist = $ ('. Product-list '));8 functionGetData () {9Notice.text (' Loading ...);Ten $.ajax ({ OneAsync:true, AType: ' Post ', - Url:url, -Data: {' page ':p age, ' bid ': Bid,}, theDataType: ' JSON ', -Success:function(msg) { - if(msg.status==1){ -Page=Msg.next; + if(msg.end==1){ -End=1; + } A for(varr=0;r<msg.result.length;r++){ atConsole.log (msg.result[0].title); -Str= ' <li><a class= "back block" title= "' +msg.result[r].title+ '" href= "' +link+msg.result[r].id+ '" style= " Background-image:url (' +rt+msg.result[r].img+ ') "></a></li>"; - plist.append (str); - } - - } inConsole.log (Msg.info);//Debug - }, toError:function(){ +Console.log (' Network failure! ‘); - } the }); * } $GetData ();//Initialize one page of dataPanax Notoginseng$ (' body '). MouseWheel (function(event) { - if(end!=1&& (' body '). ScrollTop () > (Plist.offset (). Top+plist.height ()-$ (window). Height ()-200))){ the GetData (); + } AConsole.log ($ (' body '). scrolltop ()); theConsole.log (Plist.offset (). top+plist.height ()); + }); -});
Ajax Data (PHP)
functionajaxlist () {if(!is_post) { $data[' status '] = 0; $data[' info '] = ' illegal request '; $this->ajaxreturn ($data, ' JSON '); }Else{ $page=intval($_post[' page ']);//Current page number $bid=intval($_post[' bid ']);//category 0 for all if($bid){ $where[' Bid ']=$bid; } $number= 6;//number of requests per request $count= M (' Product ')->where ($where),Count();//Total Quantity $pageCount=Ceil($count/$number);//Total Pages /*Start Request*/ if($page>$pageCount){ $data[' status '] = 0; $data[' info '] = ' No More new films '; $this->ajaxreturn ($data, ' JSON '); }Else{ $sql= M (' Product '); $result=$sql->where ($where)->order (' Sort desc,id desc ')->limit (($number*($page-1)). ', '.$number),Select (); $data[' status '] = 1; $data[' result '] =$result; $data[' sql '] =$sql-Getlastsql (); if($page==$pageCount){ $data[' Next '] =$page; $data[' info '] = ' new piece Loaded all '; $data[' End '] = 1; }Else{ $data[' Next '] =$page+1; $data[' info '] = ' Click to load More '; } $this->ajaxreturn ($data, ' JSON '); } } }
JS pull-down automatic loading