Skip to content

Instantly share code, notes, and snippets.

@TravelingTechGuy
Created April 22, 2013 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TravelingTechGuy/5432343 to your computer and use it in GitHub Desktop.
Save TravelingTechGuy/5432343 to your computer and use it in GitHub Desktop.
Show a spinner when starting a jQuery AJAX call, and hide when the call is done
$(document)
.ajaxSend(function() {
$('#spinner').show();
})
.ajaxStop(function() {
$('#spinner').hide();
})
.ajaxError(function() {
$('#spinner').hide();
$('#message').text('Error occurred');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment