How to easily listen for xhr requests with Javascript?
In javascript, you can redefine any function or object on the fly. For your problem, you can try something like this:
var original_xhr = XMLHttpRequest;
XMLHttpRequest = function () {
/* logic that notifies your plugin goes here */
...
original_xhr();
alert ("I redefined this function");
Here is the complete version of Travis J Webb's solution. Just put this near the top of your JS or HMTL file.
(function(){
var original_xhr = XMLHttpRequest;
window.XMLHttpRequest = function () {
/* logic that notifies your plugin goes here */
original_xhr.apply(this, Array.prototype.slice.call(arguments));
alert ("I redefined this function");
}
}());