Show Loader till Ajax Call not Completed in Magento 2

Add the following code to show the loader till ajax call is not completed in Magento 2

jQuery.ajax({
    url: url,
    type: 'POST',
    dataType: 'json',
    showLoader: true //use to display loader 
}).done(function (data) {
    return true;
});

To start the loader on the ajax call, add the following code

jQuery(‘body’).trigger(‘processStart’);

To stop the loader on the ajax call, add the following code

jQuery(‘body’).trigger(‘processStop’);
We are providing the best Magento 2 Extensions at the lowest prices.
Related Products