//文档准备就绪函数
$(function () {
lists();
})
//显示信息
function lists() {
$.ajax({
url: "http://localhost:51071/api/User",
type: "get",
success: function (data) {
//清空tbd
$("#tbd").empty();
for (var item in data) {
//进行拼接
$("#tbd").append(
"
" +//依次获取字段
"
" +"
" + data[item].Name + "" +"
" + data[item].RealName + "" +"
" + data[item].Telphone + "" +"
" + data[item].Pass + "" +"
" + (data[item].Status==0?"禁用":"启用") + "" +"
" +"
" +"
");}
}
});
}
function Delete(id) {
if (confirm("确认删除?")) {
$.ajax({
url: "http://localhost:1234/api/Student/" + id,
type: "delete",
success: function (data) {
if (data > 0) {
alert("删除成功!共删除了" + data + "条数据");
location.reload();
}
else {
alert("删除失败!");
}
}
});
}
}
// 跳转修改页面
function Edit(id) {
location.href = '/User/Edit/' + id;
}
// 全选
$("#CkAll").click(function () {
$(".Ck").prop("checked", $(this).prop("checked"))
})
//批量删除
function PatchDel() {
if (confirm("确认删除?")) {
var ids = [];
$(".Ck:checked").each(function () {
ids.push($(this).val());
});
$.ajax({
url: "http://localhost:51071/api/User?ids=" + ids,
type: "delete",
success: function (data) {
if (data > 0) {
alert("删除成功!共删除了" + data + "条数据");
location.reload();
}
else {
alert("删除失败!");
}
}
});
}
}