Tal Cohen
Tal Cohen

Reputation: 1063

How do you intercept xhr POST parameters / POST body?

I know how to intercept AJAX calls with XMLHttpRequest.

I looked at the docs and there is no mentioning of the parameters (POST body) .

How do I intercept those using XMLHttpRequest.

I'm trying to keep track of all the AJAX requests run on a web page.

Thanks!

Upvotes: 4

Views: 1800

Answers (1)

Tal Cohen
Tal Cohen

Reputation: 1063

This is how you do it:

XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send; 
var newSend = function(vData) { console.log("data: " + vData); this.realSend(vData); };
XMLHttpRequest.prototype.send = newSend;

Upvotes: 8

Related Questions