解決Easyui 多選選中傳值到後臺
阿新 • • 發佈:2019-01-31
function removeit(){
var row = $('#dg').datagrid('getSelections');
var id=[];
for(i=0;i<row.length;i++){
id.push(row[i].acid);
}
//alert(id);
if (id == undefined)return;
$.messager.confirm('確定','您確定要刪除嗎',function(t){
if(t)
{
$.ajax({
url : "deleteAccount.xtml",
traditional:true,
type : "post",
dataType : "json",
data : {
'id' : id
},
success:function(data){
//console.log(data.status);
if(data.status == 1){
location.href="manage.jsp";
}
}
});
}
})
var row = $('#dg').datagrid('getSelections');
var id=[];
for(i=0;i<row.length;i++){
id.push(row[i].acid);
}
//alert(id);
if (id == undefined)return;
$.messager.confirm('確定','您確定要刪除嗎',function(t){
if(t)
{
$.ajax({
url : "deleteAccount.xtml",
traditional:true,
type : "post",
dataType : "json",
data : {
'id' : id
},
success:function(data){
//console.log(data.status);
if(data.status == 1){
location.href="manage.jsp";
}
}
});
}
})
}
//後臺接收
/**
* 根據ID單個刪除使用者
* @param acid
*/
@RequestMapping(value="/deleteAccount")
public @ResponseBody Map<String, String> deleteAccount(String id[]){
Map<String, String> map = new HashMap<String, String>();
int acid ;
String status=null;
for (int i = 0; i < id.length; i++) {
acid=Integer.parseInt(id[i]);
accountService.deleteAccount(acid);
map.put("status", "1");
}
return map;
}