1) Go to cssload.net and configure a spinner with shape, colors, speed and size. Download the code.
2) Put the style code into a css file
3) Put the div code into your html file, such as:
<div id="loadingDiv">
Please wait...
<div id="spinnerDiv">
<div id="blockG_1" class="facebook_blockG">
</div>
<div id="blockG_2" class="facebook_blockG">
</div>
<div id="blockG_3" class="facebook_blockG">
</div>
</div>
</div>
where the #spinnerDiv is the actual div from cssload.
4) In a js file, add the following jquery lines:
//*******************************
// Loading div animation
$(document).ajaxStart(function(){
$("#loadingDiv").css("display","block");
});
$(document).ajaxComplete(function(){
$("#loadingDiv").css("display","none");
});
the ajaxStart is called whenever an ajax call starts;
the ajaxComplete is called when the same call is completed.
5) If you do not want to see the spinner when the page is first loaded, make sure to add the following in your css file:
#loadingDiv{
display:none;
}