Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created September 19, 2011 14:07
Show Gist options
  • Save daGrevis/1226567 to your computer and use it in GitHub Desktop.
Save daGrevis/1226567 to your computer and use it in GitHub Desktop.
Spinner/loader in specified place before AJAX request (shows only if request has taken more than X milliseconds)
//var i, interval_id;
//var interval_id;
var timeout_id;
//i = 0;
//interval_id = setInterval(function() {
timeout_id = setTimeout(function() {
// ++i;
// if (i == 1000) {
$('.place_for_spinner').html('...');
// }
//}, 1);
}, 1000);
$.post('over/the/rainbow', function() {
// clearInterval(interval_id);
clearTimeout(timeout_id);
$('.place_for_spinner').remove();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment