Skip to content

Instantly share code, notes, and snippets.

@mrchess
Created February 13, 2012 20:57
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mrchess/1820380 to your computer and use it in GitHub Desktop.
Save mrchess/1820380 to your computer and use it in GitHub Desktop.
Exposes a variable openHTTPs which keeps track of how many XMLHttpRequests you have active.
<script>
(function() {
var oldOpen = XMLHttpRequest.prototype.open;
window.openHTTPs = 0;
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
window.openHTTPs++;
this.addEventListener("readystatechange", function() {
if(this.readyState == 4) {
window.openHTTPs--;
}
}, false);
oldOpen.call(this, method, url, async, user, pass);
}
})(XMLHttpRequest);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment