Reputation: 583
so we have this ajax option beforeSend
$.ajax({
beforeSend: function(){
// to do
}
});
is there a way to override this globally?
for example, i want to insert a function on all ajax and I want to do this by creating a single function rather than going all $.ajax calls one by one.
Upvotes: 0
Views: 2262
Reputation: 2664
You can check the .ajaxStart() - it's global for all AJAX calls.
Whenever an Ajax request is about to be sent, jQuery checks whether there are any other outstanding Ajax requests. If none are in progress, jQuery triggers the ajaxStart event. Any and all handlers that have been registered with the .ajaxStart() method are executed at this time.
More info @ https://api.jquery.com/ajaxStart/
Upvotes: 2