How to handle single Ajax Error for Entire page using jquery
        Posted  
        
            by 
                Thiyagarajan
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Thiyagarajan
        
        
        
        Published on 2012-10-16T10:54:33Z
        Indexed on 
            2012/10/16
            11:00 UTC
        
        
        Read the original article
        Hit count: 236
        
jQuery
In My page i am sending data to server side using 8 ajax call...
I don't want to handle ajax error for each and every ajax call......
Single ajax error handle all the ajax error in entire page....
is their any inheritance is possible for the entire page..
 function SendConfirmationEmail(ShipmentID, ChannelOrderReference) {
var Url = '<%=Url.Action("SendShipmentEmail","Shipments") %>';
$.ajax({
    cache: false,
    type: "POST",
    data: 'strOrderShipmentId=' + ShipmentID + '&channelOrderReference=' + ChannelOrderReference,
    url: Url,
    datatype: "HTML",
    success: function (data) {
        if (data == "1") {
            SucessErrorMessageDisplay('DivStatus', 'lblStatus', 'imgStatus', 0, 'Email is successfully sent for Order#' + ChannelOrderReference + '');
        }
        if (data == "-2") {
            SucessErrorMessageDisplay('DivStatus', 'lblStatus', 'imgStatus', 0, 'Email Template is not Choosen for this Store');
        }
        if (data == "-1") {
            SucessErrorMessageDisplay('DivStatus', 'lblStatus', 'imgStatus', 0, 'Problem in Sending Email for Order#' + ChannelOrderReference + '');
        }
        if (data == "0") {
            SucessErrorMessageDisplay('DivStatus', 'lblStatus', 'imgStatus', 0, 'Connection Failed to Send Email for Order# ' + ChannelOrderReference + '');
        }
        if (data == "-3") {
            SucessErrorMessageDisplay('DivStatus', 'lblStatus', 'imgStatus', 0, 'ShipTo Email Address is Not Given for Order# ' + ChannelOrderReference + '');
        }
        // SucessErrorMessageDisplay('DivStatus', 'lblStatus', 'imgStatus', 0, 'Order# :' + ChannelOrderReference + ' is voided successfully');
    },
    error: function (xhr, ajaxOptions, thrownError) {
        if (xhr.status == 403) {
            window.location.href = '<%: Url.Action( "SessionExpire", "Home" ) %>';
        }
    }
});
}
© Stack Overflow or respective owner