使用laravel中的ajax更新购物车产品时出错

I want to update my shopping cart product using ajax.

It works only on first product not whole cart product and When i update the quantity value it not reflect on total price..

But when i refresh the page it reflect in total price..

shoppingcart_blade :

<input type="hidden" name="product_id" id="product_id<?php echo $count; ?>" value="{{ $cartproduct->id }}"/>

<input type="number" name="qty" min="1" max="20" id="updateQty<?php echo $count; ?>" value="{{ $cartproduct->qty }}" class="btn-qty-cart" autocomplete="off"/>
<input type="hidden" id="rowId<?php echo $count; ?>" value="{{ $cartproduct->rowId }}" name="rowId"/>  

<script type="text/javascript">

<?php for($i=1;$i<30;$i++){ ?>
$('#updateQty<?php echo $i; ?>').on('change keyup',function(){

    var qty = $('#updateQty<?php echo $i; ?>').val(); 
    var rowId = $('#rowId<?php echo $i; ?>').val(); 
    var product_id = $('#product_id<?php echo $i; ?>').val();

    if(qty<=0)
    {
        alert('Enter only valid Quantity');
    }
    else
    {
        $.ajax({ 
        type: "get", 
        url: "<?php echo url('shopping_cart/'); ?>/"+product_id, 
        data: { 
        'qty': qty, 
        'rowId': rowId,
        'product_id' :product_id, 
        }, 
        success: function(data) { 
        //alert(data); 
        //console.log(data); 
        } 
        });
    }

});
<?php } ?>
</script>  

Controller :

public function updateCartQuantity(Request $request,$id)
    {
        $product_id=$request->product_id;
        Cart::update($request->rowId,$request->qty);

        return redirect()->back();
    }

If you want to call ajax for dynamic data and change any thing into database then you have to call ajax only one time and send the data dynamically.. In your case you are calling ajax in loop for 30 times, that not right way to call dynamic data..

You need to set total price value using jquery, because without page refresh your changes not reflect.