0

私はMVC2を使用していて、ユーザーにわかりやすいエラーメッセージを表示しようとしています。方法は次のとおりです。

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

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

ただし、ajaxOnFailureコールバックでそれを読み取る方法を見つけるのに問題があります。

function ajaxErrorHandler(context) {

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


}

私はfirebugで応答が正しいことを見ることができます。何か案は?

4

2 に答える 2

1

コードは次のとおりです。

alert(context.get_data());

これは「ひどくエラー」を表示します

于 2012-05-04T18:42:15.760 に答える
0

次のことを試してください:onFailureコールバック内のcontext.get_message()...

function OnFailure(context){alert(context.get_message());

    }

これは私を助けてくれました。--Sudipto www.supernovaservices.com

于 2013-07-07T06:40:36.017 に答える