Javascript examples for jQuery Method and Property:ajaxSetup
Set the default URL and error function for all AJAX requests:
<!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(){ $.ajaxSetup({url:"wrongfile.txt",error:function(xhr){ console.log("An error occured: " + xhr.status + " " + xhr.statusText); }});/*from w w w .j a v a 2 s . c om*/ $.ajax(); }); }); </script> </head> <body> <p>Artists</p> <div></div> <button>test</button> </body> </html>