<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<script src="http://code.jquery.com/jquery.js"></script> | |
<script src="../bootstrap/js/bootstrap.min.js"></script> | |
<body> | |
<table border="1px" id="head"> | |
<thead class="success"> | |
<td>uid</td> | |
<td>username</td> | |
<td>pwd</td> | |
</thead> | |
</table> | |
<button id="lastbtn">上一页</button> | |
<button id="nextbtn">下一页</button> | |
<script> | |
$(function () { | |
var pagesize=3; | |
var pagenum=1; | |
$.ajax({ | |
url:"/pageservlet", | |
type:"post", | |
data:{"pagesize":+pagesize,"pagenum":+pagenum}, | |
dataType:'json', | |
success:function (data) { | |
//console.log("获取到了数据"); | |
//console.log(data); | |
$.each(data,function(index,value){ | |
var chitr=$("<tr/>"); | |
console.log(value); | |
// console.log("22222") | |
$.each(value,function (i,valuetd) { | |
//console.log("进入"); | |
var chitd=$("<td/>"); | |
console.log(i); | |
if(i=="uid"){ | |
chitd.html(value.username); | |
} | |
if(i=="username") | |
{ | |
chitd.html(value.password); | |
} | |
if(i=="password") | |
{ | |
chitd.html(value.uid); | |
} | |
//chitd.html(valuetd); | |
console.log(valuetd) | |
$(chitr ).append(chitd); | |
}) | |
//console.log( index , listReceive[index] ); | |
//创建节点 | |
$("table#head").append(chitr); | |
}); | |
},error(e){ | |
console.log("2222") | |
} | |
}) | |
//上一页 | |
$("#lastbtn").on("click",function () { | |
pagenum=pagenum-1; | |
$("thead").siblings().empty(); | |
$.ajax({ | |
url:"/pageservlet", | |
type:"post", | |
data:{"pagesize":+pagesize,"pagenum":+pagenum}, | |
dataType:'json', | |
success:function (data) { | |
console.log("获取到了数据"); | |
console.log(data); | |
$.each(data,function(index,value){ | |
var chitr=$("<tr/>"); | |
console.log(value); | |
// console.log("22222") | |
$.each(value,function (i,valuetd) { | |
console.log("进入"); | |
var chitd=$("<td/>"); | |
console.log(i); | |
if(i=="uid"){ | |
chitd.html(value.username); | |
} | |
if(i=="username") | |
{ | |
chitd.html(value.password); | |
} | |
if(i=="password") | |
{ | |
chitd.html(value.uid); | |
} | |
//chitd.html(valuetd); | |
console.log(valuetd) | |
$(chitr ).append(chitd); | |
}) | |
//console.log( index , listReceive[index] ); | |
//创建节点 | |
$("table#head").append(chitr); | |
}); | |
},error(e){ | |
console.log("2222") | |
} | |
}) | |
}) | |
//下一页 | |
$("#nextbtn").on("click",function () { | |
pagenum=pagenum+1; | |
$("thead").siblings().empty(); | |
$.ajax({ | |
url:"/pageservlet", | |
type:"post", | |
data:{"pagesize":+pagesize,"pagenum":+pagenum}, | |
dataType:'json', | |
success:function (data) { | |
console.log("获取到了数据"); | |
console.log(data); | |
$.each(data,function(index,value){ | |
var chitr=$("<tr/>"); | |
console.log(value); | |
// console.log("22222") | |
$.each(value,function (i,valuetd) { | |
//console.log("进入"); | |
var chitd=$("<td/>"); | |
console.log(i); | |
if(i=="uid"){ | |
chitd.html(value.username); | |
} | |
if(i=="username") | |
{ | |
chitd.html(value.password); | |
} | |
if(i=="password") | |
{ | |
chitd.html(value.uid); | |
} | |
//chitd.html(valuetd); | |
console.log(valuetd) | |
$(chitr ).append(chitd); | |
}) | |
//console.log( index , listReceive[index] ); | |
//创建节点 | |
$("table#head").append(chitr); | |
}); | |
},error(e){ | |
console.log("2222") | |
} | |
}) | |
}) | |
}) | |
</script> | |
</body> | |
</html> |
分页
最新推荐文章于 2025-05-24 10:48:31 发布