使用layui分页
<link rel="stylesheet" href="css/layui.css">
<div id="test1"></div>
<script src="js/layui.js"></script>
var js_total=0;
function aaa(total){
layui.use(['laypage'], function() {
var laypage = layui.laypage;
laypage.render({
elem: 'test1'
,count: total
,limit: 20
,limits: [20, 30, 50]
,layout: ['count', 'prev', 'page', 'next', 'limit']
,jump: function(obj, first){
console.log(obj.curr);
console.log(obj.limit);
if(!first){
serch(obj.curr,obj.limit);
}
}
});
});
}
function getTotal(){
$("#tbodyRwfp").html("");
var queryksnd = $("#queryksnd").val();
var querykc = $("#querykc").val();
$.ajax({
type: "POST",
url: "dataTj.do?method=getStbTotal&queryksnd="+queryksnd+"&querykc="+querykc,
dataType:'json',
async: 'false',
error:function(XMLHttpRequest){
alert(XMLHttpRequest.responseText);
},
success: function(data){
if(data.isTrue){
js_total=data.total;
console.log(js_total);
aaa(js_total);
if(js_total>0){
serch(1,20);
}
}else{
alert(data.errMsg);
return;
}
}
});
}
function serch(page,limit){
var queryksnd = $("#queryksnd").val();
var querykc = $("#querykc").val();
$.ajax({
type: "POST",
url: "dataTj.do?method=getStbDownladTj&queryksnd="+queryksnd+"&querykc="+querykc+"&page="+page+"&limit="+limit,
dataType:'json',
async: 'false',
error:function(XMLHttpRequest){
alert(XMLHttpRequest.responseText);
},
success: function(data){
if(data.isTrue){
var list = data.list;
console.log(list)
var pyrwList = data.list;
$("#tbodyRwfp").html("");
for(var i=0;i<pyrwList.length;i++){
var pyrwMap = pyrwList[i];
var ssmc = pyrwMap["SSMC"];
var kc = pyrwMap["KC"];
var f = (pyrwMap["F"]=="0"?"否":"是");
var s = (pyrwMap["S"]=="0"?"否":"是");
var pyrwStr = "<tr align='center'><td>"+ssmc+"</td>";
pyrwStr += "<td>"+kc+"</td>";
pyrwStr += "<td>"+f+"</td>";
pyrwStr += "<td>"+s+"</td>";
pyrwStr += "</tr>";
$("#tbodyRwfp").append(pyrwStr);
}
}else{
alert(data.errMsg);
return;
}
}
});
}
|