开发者

jQuery - Detect all ajax request on page

开发者 https://www.devze.com 2023-02-14 08:25 出处:网络
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

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开发者_如何学C, and raise a callback event when the request is complete.

Is this possible?

If so how?


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
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消