JQuery Ajax error resolution

I am working on a stripes application that uses jQuery bit to make the user interface more dynamic / useful.

I set the error resolution, so if an error occurs, the user is redirected to the error.jsp page.

However, if an error occurs during a jQuery Ajax call, instead of redirecting to the error.jsp page, I get html printed on the page where the call should have been.

How do I pass jQuery for redirection if an exception is thrown instead of printing to the page?

Ajax violation example:

$.post("SendStatusEmail.action",
            {status: newstatus, id : id },
            function(data) {
                column.text(data);
                column.addClass("redfont");
                column.parent().fadeOut(3000, function(){column.parent().remove()});
+3
source share
2 answers
$(document).ajaxError(function(event, XMLHttpRequest, ajaxOptions, thrownError) {
    // redirect here.
}

, , Ajax . JSON .

+3

$.ajax() $.post()? $.ajax() , .

+4

Source: https://habr.com/ru/post/1699118/


All Articles