vondip
vondip

Reputation: 14039

jQuery - Detect all ajax request on page

I am using a report viewer in My webpage. I have decided I need to add some custom abilities to it (ui wise). For that I've utilized some jquery libraries. Problem arises when the control sends ajax controls to the remote server. I need to somehow get notified about them, and raise a callback event when the request is complete.

Is this possible?

If so how?

Upvotes: 2

Views: 9167

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038830

You could use the $.ajaxSetup() function which allows you to register global properties for all ajax requests (issued by jQuery). For example:

$(function() {
    $.ajaxSetup({
        complete: function(xhr, textStatus) {
            // will be raised whenever an AJAX request completes (success or failure)
        },
        success: function(result) {
            // will be raised whenever an AJAX request succeeds
        },
        etc ... you could use any available option
    });
});

Upvotes: 14

Related Questions