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.
No you there isn't any place in the API exposed by XMLHttpRequest that allows you to override its default behaviour of following a 301 or 302 automatically.

If the client is running IE on windows then you can use WinHTTP instead to set an option to prevent that behaviour but thats a very limiting solution.