Articles → JQUERY → Ajaxerror Method In Jquery

Ajaxerror Method In Jquery






Purpose





Example


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        $(document).ready(
            function() {              
                $("a").click(
                    function () {
                        $.ajax({
                            type: "POST",
                            url: "abc/abc.php",
                            dataType: "JSON",
                            async: false,
                            success: function (data) {
                            }
                        });
                    });

                $(document).ajaxError(function () {
                    alert("An error occured!");
                });
            });
    </script>

</head>
<body>
    <a href="#">Click Me</a>      
</body>
</html>





Output


Picture showing the output of ajax error example
Click to Enlarge

Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, August 29, 2018

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250