Q:

Register a handler to be called when Ajax requests complete with an error using jquery

0

Register a handler to be called when Ajax requests complete with an error  using jquery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code:

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
 <meta name="viewport" content="width=device-width">
 <title>Register a handler to be called when Ajax requests complete with an error.</title>
 </head>
 <body>
 <button class="trigger">Click to see the file content</button>
 <div class="result"></div>
 <p class="log"></p>
 </body>
 </html>

JavaScript Code :

$( document ).ajaxError(function() {
  $( ".log" ).text( "File not present." );
});

$( "button.trigger" ).on( "click", function() {
  $( ".result" ).load( "https://www.w3resource.com/jquery-exercises/jq-ajax-test.php" );
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now