I agree with the answer above, there are many great css spinner solutions so use those. I personally would: Inside the event function that triggers the AJAX call, simply use
$('.spinner').show();
and then in the AJAX success callback
$('.spinner').hide();
Like this, just for example:
(I'm assuming that if you know how to use AJAX, you can work out how to make a CSS spinner. There are lots of resources and plugins available.)
$('.ajax-trigger').click(function () {
$('.spinner').show();
$.ajax({
url: 'http://test.blah.com/test.php',
data: {
format: 'json'
},
error: function() {
$('.spinner').hide();
$('#info').html('<p>An error has occurred</p>');
},
dataType: 'json',
success: function(data) {
$('.spinner').hide();
$('#info').html('<p>Success</p>');
},
type: 'GET'
})
});