jQuery ajax - ajaxSuccess() method

Example

Trigger a prompt box when the AJAX request is successfully completed:

$("div").ajaxSuccess(function(){
  alert("AJAX request has been successfully completed");
)

Try It Yourself

Definition and Usage

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

Detailed Description

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

Regardless of when the Ajax request is successfully completed, jQuery will trigger the ajaxSuccess event. At this time, any function registered by .ajaxSuccess() will be executed.

Syntax

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

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

Additional parameters:

  • event - Includes event object
  • xhr - Includes XMLHttpRequest object
  • options - Includes options used in AJAX request

Example

Display message after AJAX request is successful:

$("#msg").ajaxSuccess(function(evt, request, settings){
  
)