jQuery > Ajax methods

.ajaxSuccess() - Knowing ajax request is successful in jQuery

How to know if ajax request is successful in jQuery?


To know if the ajax request is successful, ajaxSuccess() method can be used.

<script>
        $(document).ajaxSuccess(function () {
            v++;
            $("#divAjaxSuccess").text("ajaxSuccess: Ajax request is successful : ");
        });
    </script>

In the above code snippet, when ajax request is successful, “ajaxSuccess: Ajax request is successful :” is written inside “divAjaxSuccess” element. We can catch this event to show any success message or to perform any activity.

Important

Note that this event only executes when ajax request is successful, it doesn't fire if an error occurred while processing the ajax request.

 Views: 5928 | Post Order: 114



Write for us






Hosting Recommendations