ajax批刪

 

<td><input type="checkbox"     name="bb"  value="{{$v->id}}"> {{$v->id}}</td>

 

<button id="pi">批刪</button>

//批量刪除ajax

$(document).on("click","#pi",function () {
nam=document.getElementsByName("bb");
str="";
for (i=0;i<nam.length;i++){
if (nam[i].checked==true){
str+=","+nam[i].value;

}
}
id=str.substr(1);
$.ajax({
url:"shan",
type:"post",
dataType:"json",
data:{
id:id
},
success:function (data) { console.log(data);
if (data==1){
location.href=""
}
}
})

})

 

function  shan(req $req){       $id= $req->post("id");       $id=explode(",",$id);     foreach ($id as $k=>$v){         $res= DB::table("poker")->delete($v);     }     return  1;}
相關文章
相關標籤/搜索