0
<script type="text/javascript">     jQuery(document).ready(function(){ jQuery('#shopping-cart-table')
    .on(
        'change',
        'input[name$="[qty]"]',
        function(){
            var form = jQuery(jQuery(this).closest('form'));    

            jQuery.ajax({
                url: form.attr('action'),
                method: form.attr('method'),
                data: form.serializeArray()
            });
        }
    ); });  </script>

I used this function for the Ajax update cart, ajax request is working but it is not updating in the cart, anybody done this ajax update cart please help me.

Naveenbos
  • 1,226
  • 2
  • 17
  • 30
  • Can show the controller code where you have send ajax request – Amit Bera Dec 29 '15 at 09:28
  • I haven't written any controller file for this, http://magento.stackexchange.com/questions/55707/auto-update-cart-quantity-when-change-quantity/70361#70361 – Naveenbos Dec 29 '15 at 09:34

1 Answers1

3

Assume that your form action url is checkout/cart/updatePost/ and have no customization at Mage_Checkout_CartController at updatePostAction().

Then you need to understand that the request to checkout/cart/updatePost does not render the cart page content. So if you tried to get the cart page content from the response, it's a waste of time. The response is a 302 redirect after the cart was updated.

So you need to use a customized cart controller.

Also make sure, that the form_key input field is present.

Fabian Schmengler
  • 65,791
  • 25
  • 187
  • 421
Amit Bera
  • 77,456
  • 20
  • 123
  • 237