Adam K Dean

Intercept AJAX requests

Published on 14 January 2014 at 09:57 by Adam

Just a snippet today, a reblog, of an article on how to Hijack AJAX Requests Like A Terrorist by Daniel Huckstep.

There are some who say not to modify prototypes because you never know how other libraries will use them, but then there are also some people who think that driving 30 MPH on a 60 MPH road is a good idea, so not everything everyone thinks is a good idea, is a good idea.

(function(open) {
  XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
    // do some magic
    open.call(this, method, url, async, user, pass);
  };
})(XMLHttpRequest.prototype.open);

This works perfectly well for intercepting AJAX requests. In my case, it is to modify the URL that is requested by AngularJS.



This post was first published on 14 January 2014 at 09:57. It was filed under archive with tags javascript, ajax.