Update cart in magento using update button

jQuery(“.btn-update”).click(function(){
var baseUrl = ‘<?php echo Mage::getBaseUrl(); ?>’;
var id = “#c”+this.id;
var quan = jQuery(id).val();
var lastChar = id.substr(id.length – 1);
var pagename = jQuery(this).attr(‘data-page’);
var onepageUrl = ‘<?php echo Mage::getBaseUrl(); ?>onepage’;
jQuery.ajax({
url: “<?php echo Mage::getBaseUrl(); ?>checkout/cart/updatePosts/”,
data: “cart[“+lastChar+”][qty]=”+quan,
async: false,
beforeSend: function(){

jQuery(‘.btn-update’).html(‘<img src=”‘+baseUrl+’ip-loader.gif”>’);
//jQuery(‘.btn-update’).css(‘top’,’-4px’);
},
success: function(html){
if(pagename==’onepage’){
sendonpage();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {

if(textStatus==’error’){
if(pagename==’onepage’){
sendonpage();
}
}

}
});
});

Advertisements