Anna K.
Anna K.

Reputation: 1995

beforeSend like fail and done

Any way to get beforeSend() to work like done() and fail() with $.ajax ?

$.ajax(..).beforeSend(function(){
  // do things before send
}).done(.....

Upvotes: 0

Views: 450

Answers (1)

MH2K9
MH2K9

Reputation: 12039

You can add beforeSend: like success:. The event inside beforeSend: function works before starting AJAX. This should work

$.ajax({
    url: 'your_url',
    data: your_data,
    type:  'get', 
    dataType: 'your data type',
    success: function(data){
        //Do after success
    },
    beforeSend: function(){
        //Do before ajax starting
    },
    complete: function(data){
        //Do after completing
    }
});

Here include details.

Upvotes: 1

Related Questions