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

jQuery ajaxSuccess() method

jQuery AJAX Methods

Every time an Ajax request is successfully completed, the ajaxSuccess() method attaches a function to be called. This is an AjaxEvent.

Every time an Ajax request is successfully completed, jQuery triggers the ajaxSuccess event. At this time, all handlers registered with the ajaxSuccess() method will be executed.

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

Syntax:

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

Example

Display a message when the Ajax request is successfully completed:

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

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

$(document).ajaxSuccess(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 the function to be executed when the request is successfully completed

Parameters:

  • event -Contain event object

  • xhr-Contain XMLHttpRequest object

  • options-Contain options used in AJAX requests

jQuery AJAX Methods