ajaxSuccess() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajaxSuccess

Description

The ajaxSuccess() method sets a function to be run when an AJAX request is successfully completed.

Syntax

Parameter Description
function(event,xhr,options) Required.

Additional parameters:

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

The following code shows how to trigger an alert box when an AJAX request completes successfully:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(document).ajaxSuccess(function(){
        console.log("AJAX request successfully completed");
    });/*w  ww.j a va  2s.c om*/
    $("button").click(function(){
        $("div").load("demo_ajax_load.txt");
    });
});
</script>
</head>
<body>

<button>test</button>

</body>
</html>

Related Tutorials