TP 手机列表页下拉加载 没有分页
Controller类创建方法
publicfunctionajaxindex($p,$cid){$articlecate=M('articlecate');$article=M('article');$listRows=6;$firstRow=($p-1)*$listRows;$data=$article->where("cateidin(".$cid.")")->limit($firstRow,$listRows)->field("id,title,pic,time,des")->select();echojson_encode($data);}
页面js输出
<scriptlanguage="javascript">$(window).on("scroll",function(){if($(document).scrollTop()>=400){$('.imorebox').click();}})varpage=1;functiongetlist(page){$.ajax({type:"GET",url:"__CONTROLLER__/ajaxindex/p/"+page+"/cid/<?phpechoI('get.cid');?>",dataType:"json",success:function(data){if(data==null||data==''){$("#imore").html('没有了');$("#imore").unbind("click");}varhtml="";$(data).each(function(k,v){html+='<li><divclass="news_title"><ahref="/index.php/Wap/News/info/id/'+v.id+'">'+v.title+'</a></div><divclass="news_des"><ahref="/index.php/Wap/News/info/id/'+v.id+'">'+v.des+'</a></div></li>';});$("#ajaxbox").append(html);}});}getlist(1);$("#imore").click(function(){getlist(++page);});</script>附件:http://down.51cto.com/data/2368679
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。