I have implemented Ajax call to add product to cart, which is somewhat like below:
$.ajax({
showLoader: true,
url: SERVER_URL+'common/custompurchase/addtocart',
data: data,
type: "POST",
dataType: 'json'
}).done(function (data) {
// some code...
});
It is working fine. But it's not showing loading icon when i call Ajax. I have also tried below answers.
$('body').trigger('processStart');
$('body').loader('show');
var body = $('body').loader(); body.loader('show');
In console it's showing this warning.
Expected to start loader but did not find one in the dom
Please provide suggestions if anybody has faced such issue.
Note: I have implemented this code on product detail page.