I would like to place a \"please wait, loading\" spinning circle animation on my site. How should I accomplish this using jQuery?
jQuery provides event hooks for when AJAX requests start and end. You can hook into these to show your loader.
For example, create the following div:
Set it to display: none
in your stylesheets. You can style it whatever way you want to. You can generate a nice loading image at Ajaxload.info, if you want to.
Then, you can use something like the following to make it be shown automatically when sending Ajax requests:
$(document).ready(function () {
$('#spinner').bind("ajaxSend", function() {
$(this).show();
}).bind("ajaxComplete", function() {
$(this).hide();
});
});
Simply add this Javascript block to the end of your page before closing your body tag or wherever you see fit.
Now, whenever you send Ajax requests, the #spinner
div will be shown. When the request is complete, it'll be hidden again.