Gloabal ajax request loader functionality

We can use defaul jQuery-ajax method for display ajax loader on multiple ajax request by using below formula.

var activeAjaxCount = 0;

$( document ).ajaxStart(function() {
activeAjaxCount++;
$(‘#msg_writter’).show();
});

$( document ).ajaxComplete(function() {
activeAjaxCount–;
if (activeAjaxCount == 0) {
$(‘#msg_writter’).hide();
}
});