jquery代码:
$('.del').click(function() {
var stuid = $(this).parent().parent().attr("id");
$.post(ctx + '/del?stuid=' + stuid,function(data) {
if(data.result == "ok"){
$("#" + stuid).fadeOut("slow", function (){
$(this).remove();
});
} else if(data.result == "error"){
alert("删除出错!");
}
});
});
jsp代码:
<table class="altrowstable" id="alternatecolor">
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>地址</th>
<th>管理员</th>
<th>操作</th>
</tr>
<c:forEach items="${stuList}" var="stu" varStatus="st">
<tr id="${stu.id }">
<td>${st.index+1 }</td>
<td><a href="" class="update" title="修改">${stu.name }</a></td>
<td>${stu.age }</td>
<td>${stu.address }</td>
<td>
<c:if test="${stu.isadmin == '0' }">
否
</c:if>
<c:if test="${stu.isadmin == '1' }">
是
</c:if>
</td>
<td><a href="#" class="del">删除</a></td>
</tr>
</c:forEach>
</table>