function deleteAll() {
var array = [];
$('input[type=checkbox]:checked').each(function() {
array.push($(this).attr('id'));
})
var s = array.toString();
// var str = '';
// for ( a in array){
// str = str+a+",";
// // str += a+",";
// }
// str = str.substring(0, str.length-1)
$.ajax({
type:"post",
url:"/stu/dels",
data:{idList: s},
success:function () {
alert("删除成功!");
for (var a in array) {
$(a).remove();
}
location.reload();
},
error:function () {
alert("删除失败!");
},
dataType :"text"
})
}
追加里面的写的:
<input type='checkbox' id='"+json.id+"' class='dels'>
controller:
@PostMapping("/dels") public String deletes(String idList){ String [] strs=idList.split(","); List<String> ids=new ArrayList<String>(); for(int i=0;i<strs.length;i++){ ids.add(strs[i]); } iStudentService.deleteStudents(ids); return "stuindex"; }