Magento cart update with ajax.

var postData = jQuery(“#checkout-cart-form”).serializeArray();
jQuery(qtyupdate).closest(‘td’).find(‘.update-cart-qty’).text(‘<?php
echo $this->__(‘Updating’);
?>…’);
jQuery(qtyupdate).closest(‘td’).find(‘.update-cart-qty’).css(‘color’,’#009640′);
jQuery.ajax({
type: “post”,
url: “<?php
echo $this->getUrl(‘checkout/cart/updatePost’);
?>”,
data: postData,
contentType: “application/x-www-form-urlencoded”,
success: function(responseData, textStatus, jqXHR) {
jQuery(‘#header-cart’).replaceWith(jQuery(responseData).find(‘#header-cart’));
jQuery(‘.layout.col1-layout’).replaceWith(jQuery(responseData).find(‘.layout.col1-layout’));
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
}
})

Leave a comment