gpt4 book ai didi

javascript - ASP.NET Ajax-OnFailure-获取错误文本

转载 作者:行者123 更新时间:2023-12-03 08:35:27 25 4
gpt4 key购买 nike

我正在使用MVC2,并尝试向用户显示友好的错误消息,方法如下:

public ActionResult Foo()
{
Response.StatusCode = 403;

return new ContentResult() { Content="frindly error"}
}

但是,我很难找到如何在ajax OnFailure回调中读取它的方法:
function ajaxErrorHandler(context) {

// this fires an error, saying it's not a JSON object
alert(context.get_response().get_object());


}

我可以在 Firebug 中看到响应是正确的。
有任何想法吗?

最佳答案

这是代码:

alert(context.get_data());
这将显示“友好错误”

关于javascript - ASP.NET Ajax-OnFailure-获取错误文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10451374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com