English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery ajaxComplete() Method

jQuery AJAX Methods

When the Ajax request is completed, the ajaxComplete() method will specify a function to be called. This is an AjaxEvent.

jQuery will trigger the ajaxComplete event every time an Ajax request is completed. At this time, all handlers registered with the ajaxComplete() method will be executed.

Note:From jQuery 1.8From version X, this method should only be attached to the document.

Syntax:

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

Example

Display a message when the Ajax request is completed:

$("(document").ajaxComplete(function(){
  $("#done").text("Ajax request completed");
});
Test See‹/›

Using event, xhr, and options parameters, you can get more useful output:

$("(document").ajaxComplete(function(event, xhr, options){
  $("#done").append(options.url);
  $("#done").append(xhr.status);
  $("#done").append(event.type);
});
Test See‹/›

Parameter Value

ParametersDescription
function(event, xhr, options)Specify a function to run when the request is completed

Parameters:

  • event -Contain event object

  • xhr-Contain XMLHttpRequest object

  • options-Contain options used in AJAX requests

jQuery AJAX Methods