In $.ajax, moved ajaxBeforeSend() call to after xhr.open(), so that custom request headers can be added