JQuery Ajax

 

The callback function is executed after the current effect is completely finished. 

In this example, we are going to use a callback function on the click of a button. The button click will initiate the load() method and then alert box message will appear on the screen after that 'lorium ipsum' web page will be shown on the screen

 
 
 
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $(".box").load("https://loremipsum.io/", function(responseTxt, statusTxt){ if(statusTxt == "success"){ alert("Now content will be loaded successfully!"); } }); }); }); </script> </head> <body> <div class="box"> <h2>Load method with function</h2> </div> <button type="button">Load Content</button> </body> </html>
Output