$.ajax now supports beforeSend.

Refactored $.ajax to handle default settings and user supplied settings
better.
Added sendBefore callback, which exposes two arguments: the xhr object
and the settings object. With these you can set headers or modify the
settings before sending an Ajax request.
When an Ajax request is doing a GET, the first argument of a Deferred
object is the json or text returned.
When an Ajax is request is doing a POST, PUT or DELETE, the first
argument of the Deferred object is the XHR.status. 200 means success.