jquery - Delete data on base of selected checkbox ids laravel 5.3 -


i getting id's alert want post these id's destroyall method in usercontroller here method through getting id's in alert

function deleteall () {     var checkedvalues = $('input:checkbox:checked').map(function() {         return this.value;     }).get();     alert(checkedvalues); } 

i want post these values through ajax , delete there route as

route::post('/user-management/user/destroyall', 'usercontroller@destroyall'); 

in destroyall method want explode , , minus head checkbox value

you need use ajax:

    $.ajax({         type    : "post",         url     : "{{ url('/user-management/user/destroyall') }}",         data    : {ids: checkedvalues, _token: "{{ csrf_token() }}"},         success : function (response) {             console.log('success', response);         },         error   : function (response) {             console.log('error', response);         },         datatype: "json"     }); 

and catch ids in controller:

public function destroyall(request $request) {     // ids     $ids = $request->input('ids');      // remove first     array_shift($ids);      // delete users id     return user::wherein('id', $ids)->delete(); } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -