marcamillion
marcamillion

Reputation: 33775

Is there anything glaringly wrong with my .ajaxSetup jquery call?

I am trying to debug some code and get to the bottom of the error.

Is there anything wrong with this:

$.ajaxSetup({ 
beforeSend: function(xhr) {  
     xhr.setRequestHeader("Accept", "text/javascript"); }
}); 

This is in jQuery by the way.

Upvotes: 1

Views: 320

Answers (1)

Terseus
Terseus

Reputation: 2212

The ajax event BeforeSend is local in every ajax call, AFAIK you can't use it in $.ajaxSetup but you can use his global version ajaxSend in this way:

$.ajaxSetup({
    ajaxSend: function(event, xhr, options) {
        /* code here */
    }
});

For more info about ajax events in jQuery and their execution order take a look here: http://docs.jquery.com/Ajax_Events

Upvotes: 2

Related Questions