Laravel Delete From Shopping Cart Using Ajax
I want to delete from Cart using Ajax, I'm adding with no problem but how can I delete without refresh the page while I have many items and may I need to delete one by one, Im pass
Solution 1:
This is because your element is dynamically updated and you should attach event again. use this code instead:
     <script>
     $(function(){ 
 $(document).on('click','.remove_item', function () { 
      var id = $(this).data('id'); 
      $.ajax({
             type: 'DELETE',
             url: "cart/"+ id,  
             data: {'_token': $('input[name=_token]').val()},
             success: function (data) {
               $('#cart_product').html(data);        
             }               
        });
       });
     });
    </script>
Post a Comment for "Laravel Delete From Shopping Cart Using Ajax"