Using a deferred object in $ .ajax
- a successful callback can be replaced by
deferred-method done() - acn callback error is replaced by
deferred-method fail() - and the full callback can be replaced by
always()
using
var jqxhr = $.ajax({
url: Config.baseUrl+"/ajax/favourites/set-favourite.ajax",
dataType: "json",
data: attrs,
type: "POST",
beforeSend: function(){
console.log("before send");
}
});
how can i implement beforeSend-callbackusing a deferred object?
Why am I not using the beforeSend-callback function inside the function $.ajax? Since the request is located inside the model instance ( http://canjs.com/docs/can.Model.model.html#section_Non_standardServices ), therefore, the model object executes the request and all the others, like manipulating the DOM in a deferred object, for example. I would like to manipulate the DOM before sending an ajax request.
How can i do this?