<a href="#" Class="del" data-id=' + data[i].Sid +'> 删除</a>//删除的页面
ajax相关代码
$(function (){
$(".del").click(function () {
var that = this;//声明变量存储当前元素
var id = $(this).attr("data-id")//获取当前元素自定义属性的值---url的id
var bool = confirm("你确定删除?")//ture/fasle
if (bool) {//true执行ajax
$.ajax({
url: 'http://localhost:51767/api/Student?id=' + id,
type: 'delete',
success: function (data) {
if (data == "成功") {
$(that).parents('tr').remove();//删除=》 location.reload()刷新页面;
alert("Ok")
}
}
})
}
else {
alert("已取消删除");
}
})
})