$("#addRelation").click(function () {
var li = [];
var roleName = $("#role").text();
$("#new input:checkbox").each(function () {
if($(this).prop("checked")){
li.push($(this).prop("id"));
}
})
var url = "/Role/"+roleName+"/relation/add";
$.ajax({
url:url,
type:"post",
contentType:"application/json;charset=utf-8",
data:JSON.stringify(li),
success:function(data){
if(data['success']){
$("#new input:checkbox").each(function () {
if($(this).prop("checked")){
$(this).parent().parent().remove();
}
})
for(var i=0;i<li.length;i++){
$("#old").append("<tr><td><input type=\"checkbox\" id="+li[i]+" /> <label for="+li[i]+">"+li[i]+"</label></td></tr>");
}
}
}
})
})
转载于:https://www.cnblogs.com/pemty/p/7478777.html