Skip to content

Instantly share code, notes, and snippets.

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 CreativeSeo33/8dcbdf5dcce2b1e35cf432b49d01c4eb to your computer and use it in GitHub Desktop.
Save CreativeSeo33/8dcbdf5dcce2b1e35cf432b49d01c4eb to your computer and use it in GitHub Desktop.
Setting up a spinner for every AJAX call, globally
// One solution might be to have an AJAX spinner in a standard location that gets shown when AJAX requests start and hidden when AJAX requests complete. To do this globally in jQuery:
// http://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara
jQuery.ajaxSetup({
beforeSend: function(xhr) {
$('#spinner').show();
},
// runs after AJAX requests complete, successfully or not
complete: function(xhr, status){
$('#spinner').hide();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment