2

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?

vondip
  • 13,809
  • 27
  • 100
  • 156

1 Answers1

14

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
    });
});
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I am not sure why, but these events don't get reached. I am using a control that is not using jquery. – vondip Mar 03 '11 at 10:08
  • @vondip, OK, the fact that the control is not using jQuery explains why those events are never reached. I am afraid that you cannot achieve this in this case or there might be some browser specific extensions. – Darin Dimitrov Mar 03 '11 at 14:09
  • @vondip to globally detect AJAX calls using native javascript http://stackoverflow.com/questions/10783463/javascript-detect-ajax-requests – Adriano Sep 11 '14 at 08:18
  • Here's what I use [jquery.ajax.tracker](https://github.com/jmb-mage/ajax-request-tracker/blob/master/jquery.ajax.tracker.js) – jmbmage May 22 '15 at 15:26