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