通过递归的方式实现分页
function getBooksByPage(url,param) {
param['page']=param.page||1;
param['limit']=param.limit||10;
$.getJSON(url,param,function (result) {
if(result.code!=0){
$("#content").html(result.msg);
return ;
}
if(result.data.length==0){
$("#content").html("暂时没有数据");
return ;
}
laytpl($("#book-card-tpl").html()).render(result.data,function(html){
$("#content").html(html);
});
laypage.render({
elem: 'page-util'
,count: result.count
,curr: param.page||1
,limit: param.limit||10
,jump: function(obj,first){
if(!first){
param.page=obj.curr;
param.limit=obj.limit;
getBooksByPage(url, param);
}
}
});
})
}