What is ajaxComplete() method in jQuery?

In jQuery, the ajaxComplete() method is used to specify a function that runs when an AJAX request completes.

Syntax

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

Parameters

This method accepts a mandatory function that accepts the following parameters.

  • event: The event object
  • xhr: The instance of XMLHttpRequest object
  • options: The options used in AJAX request.

Example

The following tab will show the ajaxComplete() function in action:

Press the “Get Product Data” button to see it in action

Console
Example of ajaxComplete() method.

Explanation

We have made a GET request on https://reqres.in/api/products to fetch some product details.

When the AJAX request completes, the ajaxComplete() method will be invoked.

Free Resources