I'm trying to overload the XMLHttpRequest.* method in JavaScript so a webpage can figure out if an Ajax request took place without using any intrusive callbacks. Now, something like this works relatively fine when using most JS frameworks:
XMLHttpRequest.prototype.getResponseHeader = function() {
alert('O hai, looks like you made an AJAX request.');
}
However, there are two catches:
- getResponseHeader can't be used as getResponseHeader anymore.
- It doesn't work in simple AJAX examples. i.e.
xmlhttp.open("GET","simple.html",false);
Is there any way JS can mirror XMLHttpRequest.open()
or any way that I can chain something to it. I've tried a million paradigms (factory, cloning, wrapping -- most resulting in infinite recursion) and nothing seems to be working. Maybe it's just impossible. Any ideas?