大家好这是我分页是用的代码希望大家可以相互交流ajax局部刷新
var pageindex = 1;
var where = "";
var Pname = "";
var sex = "";
$("#sele").click(function () {
Pname = $("#Pname").val();
sex = $("#sex").val();
where = " Pname like'%" + Pname + "%'";
if (sex != "") {
where += " and Sex=" + sex + ""
}
Show(pageindex, where);
})
Show(pageindex, where);
function Show(pageindex, where) {
var pagesize = 2;
$.ajax({
type: "get",
dataType: "json",
url: "/Home/show",
data: { pageindex: pageindex, pagesize: pagesize, where: where },
success: function (data) {
var add = "";
var infor = eval(data);
$("#Showinfor").empty();
for (var i = 0; i < infor.list.length; i++) {
add += "<tr><td>" + infor.list[i].Pid + "</td>";
add += "<td>" + infor.list[i].Pname + "</td>";
add += "<td>" + infor.list[i].Sex + "</td>";
add += "<td>" + infor.list[i].Age + "</td>";
add += "<td>" + infor.list[i].Pboy + "</td>";
add += "<td>" + infor.list[i].Xname + "</td>";
add += "<td><a href='#'>删除</a>  <a href='#'>修改</a></td></tr>";
}
$("#Showinfor").append(add);
fen(infor.count, pagesize);
$("td").attr("align", "center")
}
})
}
function fen(count, pagesize) {
//Pname = $("#Pname").val();
//sex = $("#sex").val();
//where = " Pname like'%" + Pname + "%'";
//if (sex != "") {
// where += " and Sex=" + sex + ""
//}
$("#yema").empty();
var ye = Math.ceil(count / pagesize);
var str = "";
for (var i = 1; i <= ye; i++) {
str += '<a href="#" style="margin-left:5px;" onclick="Show('+i+', where)">' + i + '</a>';
}
str += "____ 共" + count + "条"
$("#yema").append(str);
}