Correction required for Angular (1.3.10)
(not required if you are using another library for your XHR needs)
MiniProfiler does this with XMLHttpRequest to be able to intercept all XHR calls for angular
XMLHttpRequest.prototype.send = function sendReplacement(data) { if (this.onreadystatechange) { ...
Well, Angular never installs xhr.onreadystatechange, so we need to handle this in a harmless way:
function createXhr() { var xhr = new window.XMLHttpRequest(); xhr.onreadystatechange = function () { }; return xhr; }
Explained in detail here
source share