Skip to content

Instantly share code, notes, and snippets.

@greggnakamura
Forked from developerdizzle/ajax-loading.js
Created June 13, 2013 13:23
Show Gist options
  • Save greggnakamura/5773613 to your computer and use it in GitHub Desktop.
Save greggnakamura/5773613 to your computer and use it in GitHub Desktop.
(function ($) {
$(function () {
var $html = $('html');
var requests = 0;
function setBusy() {
if (++requests == 1) {
$html.addClass('busy-cursor');
}
}
function setReady() {
if (--requests == 0) {
$html.removeClass('busy-cursor');
}
}
$html.ajaxStart(setBusy).ajaxStop(setReady);
if (Sys) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm) {
prm.add_initializeRequest(setBusy);
prm.add_endRequest(setReady);
}
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment