Javascript examples for jQuery Method and Property:load
Check status and show error message for load method
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").load("wrong.xml",function(response, status, xhr){ if (status == "success"){ //would not arrive here } else {/*ww w. j a v a2 s . c o m*/ $("div").html("An error occured: <br>" + xhr.status + " " + xhr.statusText) } }); }); }); </script> </head> <body> <div></div> <button>Test</button> </body> </html>