1

I need to update quantity of cart items without reloading whole page(using ajax) but with simple code not a lengthy method. anybody please help me out.

  • Which magento version – Amit Bera Apr 29 '16 at 10:59
  • magento 1.9 version – Keith Apr 29 '16 at 11:00
  • 1
    Suggestion to be use any 3rd party extension – Amit Bera Apr 29 '16 at 11:01
  • Without a lengthy method. you cannot do it – Amit Bera Apr 29 '16 at 11:02
  • i need customization without third party extension – Keith Apr 29 '16 at 11:07
2

Use below code:

<script>
jQuery(document).ready(function(){
jQuery('.btn-update').on('click',
        function(e){
            e.preventDefault();
            var form = jQuery(jQuery(this).closest('form'));

            // we'll extract the action and method attributes out of the form

            // kick off an ajax request using the form's action and method,
            // with the form data as payload
            jQuery.ajax({
                url: form.attr('action'),
                method: form.attr('method'),
                data: form.serializeArray()
            });
        }
    );
});
</script>

Hope it will helpful to you.

| improve this answer | |
  • When i am refreshing cart page it's updating cart not on click of "Update" button. – Magecode Aug 24 '17 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.