If you are using JQuery to make AJAX calls you can use something among the lines:
jQuery.ajax({
url: 'url_to_send_ajax_request_to',
beforeSend: function(XMLHttpRequest) {
jQuery('#id_of_some_div_that_contains_loading_text').show();
},
complete: function(XMLHttpRequest, textStatus) {
jQuery('#id_of_some_div_that_contains_loading_text').hide();
}
});
The beforeSend handler can be used to show a hidden div containing your loading text or image while complete handler will be used to hide it (no matter whether the call succeeds or not).
Or if you want to set it up globally for all AJAX requests you can use the ajaxSetup function:
jQuery.ajaxSetup({
beforeSend: function(XMLHttpRequest) {
jQuery('#id_of_some_div_that_contains_loading_text').show();
},
complete: function(XMLHttpRequest, textStatus) {
jQuery('#id_of_some_div_that_contains_loading_text').hide();
}
});