\!h Ajax query jQuery
jQuery.ajax({
method: 'get',
url: '<?php echo $block->getUrl('prospapay/index/calculate') ?>',
data: { price: price, form_key: FORM_KEY }
}).success(function(transport) {
jQuery('.prospapay-instalment-amount').text(transport);
});
\!h Ajax query prototype
new Ajax.Request('<?php echo $block->getUrl('prospapay/index/calculate') ?>', {
method: 'get',
parameters: {price: price, form_key: FORM_KEY},
dataType: "html",
onSuccess: function(transport) {
if (transport.status == 200){
jQuery('.prospapay-instalment-amount').text(transport.responseText);
checkMinMaxAmount(price);
}
}
});
\!h Ajax query listener magento 2 product add to cart exmaple
jQuery(document).ajaxComplete(function (event, xhr, settings) {
if (settings.url.indexOf("customer/section/load/?sections=cart") > 0) {
cartObj = xhr.responseJSON;
console.log(cartObj);
console.log('ex tax: ' + cartObj.cart.subtotal_excl_tax);
console.log('inc tax: ' + cartObj.cart.subtotal_incl_tax);
console.log('subtotal: ' + cartObj.cart.subtotal);
}
});