imrulhasan273
1 month ago

How can I update the cart in a the tag using the `ajax` data in Laravel?

Posted 1 month ago by imrulhasan273
$.ajax({
	type:'get',
        data:{'id':ID},
        url:"{{ route('ajaxcart') }}",
        success:function(data){
        alert(data);

        $('itemCountAjax').val(data);
        $('itemCountAjax').val(data);
        },
        error:function(){
        }
});

Here is my AJax method without page refresh. I have get the respose data from controller to this method. Here data contains the single integer for example 4 or 5 or 6 etc. Now I want to update the cart items without refresh.

_header.blade.php

<span class="itemCountAjax">{{ $itemCount ?? '' }}</span>

here in this <span> tag $itemsCount contains number of items added to cart. After executing ajax method I want the $itemCount to be set to value of data which is from the ajax method.

Please sign in or create an account to participate in this conversation.