jQuery ajaxComplete()Method

jQuery AJAX 方法jQuery AJAX Methods

Example

Display a "loading" indicator while an AJAX request is in progress:

$(document).ajaxStart(function(){ $("#wait").css("display","block"); }); $(document).ajaxComplete(function(){ $("#wait").css("display","none"); });

Try it Yourself »

Definition and Usage

The ajaxComplete() method specifies a function to run when the AJAX request completes.

Note:As of jQuery version 1.8, this method is only attached to the document.

Unlike ajaxSuccess(), functions specified via the ajaxComplete() method will run when the request completes, even if the request was not successful.


Syntax

$(document).ajaxComplete(function(event,xhr,options))

Parameter Description
function(event,xhr,options) Required. Specifies the function to run when the request completes.
Additional parameters:
  • event- Contains the event object
  • xhr- Contains the XMLHttpRequest object
  • options- Contains the options used in the AJAX request


jQuery AJAX 方法jQuery AJAX Methods

Other extensions