在ajax调取成功后
html:
<div id="text3"></div>
js:
$.ajax({
url: url,
type: 'post',
data: data_form,
dataType: 'json',
beforeSend: function() {},
success: function(res) {
console.log(res)
var data_info = res.data;
$('#ranchInfoView').html(template('ranchInfoView_template', data_info));
if(data_info.BranchList != null) {
var totalRecords = res.data.total; //记录总数
} else {
var totalRecords = res.data.page.totalCount; //记录总数
}
//alert(totalRecords);
layui.use(['laypage', 'layer'], function(res) {
var laypage = layui.laypage,
layer = layui.layer;
//完整功能
laypage.render({
elem: 'text3',
page: true //
,limit: 20,
curr: currPage,
count: totalRecords,
first: '首页',
last: '尾页',
layout: ['', 'prev', 'page', 'next', '', '', ''],
jump: function(obj, first) {
console.log(obj)
if(!first) {
currPage = obj.curr;
ranchInfoView();
}
}
});
});
},
error: function(res) {
console.log(res)
}
});