jQuery ajaxSuccess() check ajax url

Description

jQuery ajaxSuccess() check ajax url

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//  ww  w. j a va 2 s .c  o  m
<script>
$(document).ready(function(){
  $(document).ajaxSuccess(function(e, xhr, opt){
    if (opt.url == "ajax.txt") {
      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>



PreviousNext

Related