Check url on ajax success - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajaxSuccess

Description

Check url on ajax success

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(document).ajaxSuccess(function(e, xhr, opt){
        if (opt.url == "demo_ajax_load.txt") {
            console.log("AJAX request successfully completed");
        };//w  ww.  j a  v  a 2 s  . c  o  m
    });
    $("button").click(function(){
        $("div").load("demo_ajax_load.txt");
    });
});
</script>
</head>
<body>

<button>test</button>

</body>
</html>

Related Tutorials