<meta charset="utf-8" />
<title></title>
<link href="Content/bootstrap.css" rel="stylesheet" />
<script src="Scripts/jquery-3.3.1.min.js"></script>
<link href="Content/pagination.css" rel="stylesheet" />
<script src="Scripts/pagination.js"></script>
<script>
$(function () {
//初次加载显示分页
$.ajax({
url: "http://localhost:49586/api/Page",
data: {PageIndex:1},
type: "get",
dataType: "json",
success: function (result) {
Pager(result.totalCount);
}
})
})
function Pager(index_Pager) {
$("#pagination").pagination(index_Pager, {
//省略号后面显示的个数
num_edge_entries: 1,
//省略号前面显示的个数
num_display_entries: 1,
prev_text: "上一页",
next_text: "下一页",
callback: CallPagerData,
//每页显示的条数
items_per_page: 2
});
}
function CallPagerData(page_index, jq) {
$.ajax({
url: "http://localhost:49586/api/Page",
data: { PageIndex: page_index+1 },
type: "get",
dataType: "json",
success: function (result) {
ShowList(result.data);
}
})
}
function ShowList(result) {
$("#list").empty();
var str = "";
$(result).each(function (i, n) {
str += "<tr>" +
"<td>"+n.Id+"</td>" +
"<td>"+n.Dtitle+"</td>" +
"<td>"+n.Dname+"</td>" +
"<td>"+n.SubTime+"</td>" +
"<td>" + n.Dinfo + "</td>" +
"<td><input id='Button1' type='button' value='修改' onclick='edit()'/></td>" +
"</tr>";
})
$("#list").append(str);
}
function Export() {
window.location.href = 'http://localhost:49586/api/Export';
}
function edit() {
location.href = '/Edit.html?id=' + "王少帅";
}
</script>
<input id="Button1" type="button" value="导出" class="btn btn-primary" onclick="Export()" />
AJAX分页以及导出
最新推荐文章于 2024-10-11 15:28:44 发布