Delete a record from table using ajax in laravel 5

后端 未结 4 896
故里飘歌
故里飘歌 2021-01-13 06:30

I want to delete the record using ajax.

view

@foreach( $products as $product )
    
        {{ $product->code         


        
4条回答
  •  佛祖请我去吃肉
    2021-01-13 07:08

    As @Rob_vH mentioned, your problem is with how you're getting the ID in your JavaScript. Try changing this:

    var dataId = $('#btnDeleteProduct').attr('data-id');
    

    to this:

    var dataId = $(this).attr('data-id');
    

提交回复
热议问题