Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.