1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

post id for data deletion using ajax showing missing required parameters in controller route

Discussão em 'Outras Linguagens' iniciado por user4221591, Novembro 3, 2024 às 16:22.

  1. user4221591

    user4221591 Guest

    I am trying to delete data via datatable delete button. But I am getting error.

    I have created route as::

    Route::resource('dealers', DealerController::class);


    My controller function::

    public function destroy($id ): JsonResponse
    {
    // removed the code block
    }


    output of php artisan route:list

    DELETE dealers/{dealer} ........... dealers.destroy › Dealers\DealerController@destroy


    ajax code block of blade php page

    $(document).on('click','.deleteProduct', function(e){
    e.preventDefault();
    var id = $(this).data("id");
    confirm("Are You sure want to delete?");
    $.ajax({
    type: "POST",
    url: "{{ route('dealers.destroy') }}"+'/'+id,
    // data: data,
    // dataType: 'json',
    success: function (data) {
    var oTable = $('#dealerTabel').dataTable();
    oTable.fnDraw(false);
    },
    error: function (data) {
    console.log('Error:', data);
    }
    });


    when I try to load the page it's showing error as::

    Missing required parameter for [Route: dealers.destroy] [URI: dealers/{dealer}] [Missing parameter: dealer].

    Continue reading...

Compartilhe esta Página