在jquery中向ELMAH捕获消息/异常

时间:2013-05-21 05:33:11

标签: ajax json asp.net-mvc-3 exception-handling elmah

在我的MVC3应用程序中,我从存储过程中返回消息。如果它“成功”,我正在向前移动,否则显示自定义错误页面。 当消息是其他内容时,我想将其捕获在ELMAH中。我面临的问题是返回消息实际上不是错误,所以我无法弄清楚如何处理它。我仍然想在ELMAH中捕获错误后显示自定义错误页面。 请帮忙。

$.ajax({
        url: "../XYZ",
        type: 'POST',
        dataType: 'text',
        async: false,
        data: JSON.stringify({ abcData: abcData, strDeb: strDeb, strCre: strCre }),
        contentType: 'application/json; charset=utf-8',
        success: function (data) {
            if (logout != "Logout") {
                if (data.toLowerCase() != "successful") {
                    **//alert(data.toString());
                    window.location.href = "../Error";**
                } else {
                    window.location.href = "../ABC";
                }
            }
        },
        error: function () {
            var sessionWindowElement = $('#SessionLayoutLogOutWindow');
            sessionWindowElement.data('tWindow').center().open();
        }
    });

0 个答案:

没有答案
相关问题