您好,我需要删除由多个复选框选中的多个用户记录,然后按Delete键并提交表单userListform
。
deleteUser()
添加了锚点<a href="javascript:void();" class="btn btn-outline-danger" onclick="deleteUser();">Delete</a>
<form method="POST" action="{{url('/user/delete')}}" id="userListform" >
Route::post('/user/delete', 'UsersController@delete');
function deleteUser(){
var $checkboxes = jQuery('#userListform input[type="checkbox"]');
checkedItems = $checkboxes.filter(':checked').length;
if(checkedItems > 0){
var status = confirm("Do you need to delete the user!!");
if (status == true) {
document.getElementById("userListform").submit();
} else {
return false;
}
}else{
alert("Please select the users to be deleted!");
}
}
我已经成功提交了表单,但是我没有使用usercontroller@delete
方法的删除功能,而是显示404错误
答案 0 :(得分:2)
以表格形式添加csrf令牌,它将起作用
答案 1 :(得分:0)
您可以尝试
in the view
<form method="POST" action="{{route('user.delete')}}" id="userListform" >
in the route
Route::post('/user/delete', 'UsersController@delete')->name('user.delete);