On Magento 2 when we submit ajax request we can add “showLoader: true” below code in ajax call and trigger processStart and processStop will show and hide loading image
$('body').trigger('processStart'); $.ajax({ url: url, type: "POST", data: formdata, async: true, contentType: false, showLoader: true, success: function (result) { $('body').trigger('processStop'); } });