I have implemented Ajax call to add product to cart, which is somewhat like below:

    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.

  1. $('body').trigger('processStart');
  2. $('body').loader('show');
  3. 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.

  • Its a default Magento bug you can check this issue on GIT : github.com/magento/magento2/issues/11904 – Amit Naraniwal Feb 11 at 11:54
  • but i have also coded ajax call for some other tasks on different pages. there it works fine. only on this page it does not work. – Khushbu Feb 11 at 12:08
  • Can you please add the screen when you call ajax? – Amit Naraniwal Feb 11 at 12:56

Your Answer

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

Browse other questions tagged or ask your own question.