Reputation: 22969
I'm intercepting, globally, for lack of a better word, all AJAX responses - Are there any elegant ways to determine what was the method (POST/PUT/GET
etc) that was originally used to perform the request that triggered the intercepted response?
Here's what I do to perform the intercepts:
(function() {
var origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener('load', function() {
if (this.readyState === 4) {
// what was the method used in the *original* request?
}
});
origOpen.apply(this, arguments);
};
})();
Upvotes: 1
Views: 71
Reputation: 89
I can't add a comment or mark this quest as a dup, not having enough reps, but I beleave this has been answered here: Ajax / XMLHttpRequest tracking using javascript
Upvotes: 1