-
-
Save CreativeSeo33/8dcbdf5dcce2b1e35cf432b49d01c4eb to your computer and use it in GitHub Desktop.
Setting up a spinner for every AJAX call, globally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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