title: Overriding XMLHttpRequest's send method
body: <p>I'm trying to log (and later modify) the data <code>XMLHttpRequest</code> sends to a server by overriding <code>XMLHttpRequest.send</code> function.</p>
  
  <p>My function logs the data correctly to the console, however the request doesn't finish, therefore the browser keeps waiting for the response indefinitely.</p>
  
  <p>Any ideas what's wrong with the code?</p>
  
  <pre class="lang-js prettyprint-override"><code>XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send;
  var newSend = function(vData) { console.log("data: " + vData); realSend(vData); };
  XMLHttpRequest.prototype.send = newSend;
  </code></pre>