If you are using jQuery to do AJAX , you can use one of 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 display a hidden div containing your loadable text or image, while the full handler will be used to hide it (whether the call is being made or not).
Or if you want to configure it 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(); } });
source share