Question: Is it possible to prevent the browser from following redirects when sending XMLHttpRequest-s (i.e. to get the redirect status code back and handle it myself)?

Answer: 
Not according to [the W3C standard for the XMLHttpRequest object](http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send%28%29-method) (emphasis added):

> 
> If the response is an HTTP redirect:
> 
> 
> 
> > 
> > If the origin of the URL conveyed by the Location header is same origin
> >  with the XMLHttpRequest origin and the
> >  redirect does not violate infinite
> >  loop precautions, **transparently
> >  follow the redirect** while observing
> >  the same-origin request event rules.
> > 
> > 
> > 
> 
> 
> 

They were [considering](http://www.w3.org/TR/2008/WD-XMLHttpRequest-20080415/#notcovered) it for a future release:

> 
> This specification does not include
>  the following features which are being
>  considered for a future version of
>  this specification:
> 
> 
> * Property to disable following redirects;
> 
> 
> 

but the [latest](http://www.w3.org/TR/XMLHttpRequest/) specification no longer mentions this.
It is not possible to handle redirect or 302 status at client side as answered in other comments. However you can prevent redirection. To do that you can set request header "X-Requested-With" with "XMLHttpRequest"
xhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
This should be done after open but before send. Example below

```
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
   if (this.readyState == 4 && this.status == 200) {
         reqObj.success(JSON.parse(this.responseText))
   } else if (this.status != 200) {
         reqObj.error(this.statusText)
   }
};
xhttp.open(reqObj.type, reqObj.url, reqObj.async);
xhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhttp.send();

```