recovery men recovery men - 1 year ago 76
Ajax Question

Delete data on base of selected checkbox ids laravel 5.3

I am getting id's currently i an alert i want to post these id's to destroyAll method in my userController
here is my method through which i am getting id's in alert

function deleteAll () {
var checkedValues = $('input:checkbox:checked').map(function() {
return this.value;

i want to post these values through ajax and delete there
route is as

Route::post('/user-management/user/destroyAll', 'UserController@destroyAll');

in destroyall method i also want to explode , and minus head checkbox value

Answer Source

You need to use 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 then catch ids in controller:

public function destroyAll(Request $request)
    // get ids
    $ids = $request->input('ids');

    // remove first

    // delete users with id
    return User::whereIn('id', $ids)->delete();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download