jQuery ajaxSuccess()
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>//from ww w . j av a 2 s . c o m <script> $(document).ready(function(){ $(document).ajaxSuccess(function(){ document.getElementById("demo").innerHTML = "AJAX request successfully completed"; }); $("button").click(function(){ $("div").load("ajax.txt"); }); }); </script> </head> <body> <p id="demo"></p> <div><h2>Here</h2></div> <button>Change Content</button> </body> </html>
The ajaxSuccess()
method sets a function to run when an AJAX request is successfully completed.
This method should only be attached to document.
$(document).ajaxSuccess(function(event,xhr,options))
Parameter | Optional | Description |
---|---|---|
function(event,xhr,options) | Required. | function to run if the request succeeds Additional parameters: event - the event object xhr - the XMLHttpRequest object options - the options used in the AJAX request |