Ajax调用中的回调错误

Error callback in Ajax call

本文关键字:回调 错误 调用 Ajax      更新时间:2023-09-26

我正在使用Jquery方法来触发Ajax调用。

function fetchQuestion(questionId,index){
    $.ajax({
        url: '${createLink(action: 'fetchQuestion')}',
        data: {id:questionId,grantAssessmentId:${grantAssessmentId}},
        cache: false,
        success: function(html) {
            $('div[id="questionContent"]').html(html);
        },
        error: function(e,status){
            console.log("inside error..")
        }
    });
}

在控制器的动作中,我抛出一个异常(throw new exception("Some Message")),为ajax调用返回500个响应。但是在错误回调中,我无法捕获它

尝试使用第三个参数,您将在那里抛出错误

http://api.jquery.com/jquery.ajax/

错误类型:Function(jqXHR jqXHR, String textStatus, String errorThrown)