jQuery中的AJAX回发

I'm having an AJAX request on the page.

Is there a way to find when a AJAX-call is triggered on the page. In jQuery or javascript to find or initiate a function with AJAX request is called on a page.

See ajaxStart and ajax events. Example:

 $("#loading").bind("ajaxSend", function(){
   $(this).show();
 }).bind("ajaxComplete", function(){
   $(this).hide();
 });

You can bind a function to a JQuery object to be completed when any AJAX call completes.

$('#status').ajaxComplete(function(event, request, settings) {
    // Do stuff here...
});

See the documentation.

If you want to set a complete function for a single AJAX call, use the low-level $.ajax() function and setting a function for the complete attribute.

$.ajax({
    // ...
    complete: function(request, settings) {
         // Do stuff here...
    },
    // ...
});

Note: the documentation seems to contradict itself in specifying the number of arguments to the complete() function. It may take some fiddling.