jQuery ajax - ajaxComplete() method

Example

Display the 'loading' indicator when the AJAX request is in progress:

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

Try It Yourself

Definition and Usage

The ajaxComplete() method executes a function when the AJAX request is completed. It is an Ajax event.

Unlike ajaxSuccess(), the function specified by the ajaxComplete() method is executed when the request is completed, even if the request was not successful.

Syntax

.jQueryajaxComplete(function(event, xhr, options))
Parameters Description
function(event, xhr, options)

Required. Specifies the function to be executed when the request is completed.

Additional Parameters:

  • event - Contains event object
  • xhr - Contains XMLHttpRequest object
  • options - Contains options used in AJAX requests

Detailed Description

XMLHttpRequest object and settings passed as parameters to the callback function.