我有一个 AJAX.RouteLink,它具有以下 AJAXOptions
new AjaxOptions
{
HttpMethod = "POST",
OnFailure = "OnFailure",
OnSuccess = "OnSuccess"
})
我的 OnFailure 方法如下所示
function OnFailure(ajaxContext) {
var response = ajaxContext.get_response();
var statusCode = response.get_statusCode();
var elem = document.getElementById('message');
elem.innerHTML = 'Sorry, the request failed with status code' + statusCode;
}
问题是,当它被调用时我收到此错误
TypeError: ajaxContext.get_response is not a function
在监视列表中,我可以看到 ajaxContext
中的 responseText
是 html。
我在这里做错了什么?
最佳答案
问题是 ajaxContext 没有 get_response 方法。它一定是我正在查看其示例的对象的旧版本。
因为我想要状态代码,所以我只使用了 ajaxContext.status 属性。
关于javascript - Ajax OnFailure 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21160980/