0
    [HttpPost]
    public ActionResult accountchange(int id, int accountid, bool activate)
    {
        // Operations
        return Json(new { Model = model, Result = true, Message = "Changed Successfully });
    }

    $('#accountchange-button').click(function () {
        alert("");
        $.post("url/accountchange/", {id:1, accountid:1, activate:1},
            function (data) { $('.result').html(data); }, "json");

    });

常に得た:

POST http://localhost/account/accountchange/ 500 (Internal Server Error)
                f.support.ajax.f.ajaxTransport.sendjquery.min.js:4
                f.extend.ajaxjquery.min.js:4
                f.each.f.(anonymous function)jquery.min.js:4
                (anonymous function)demo:105
                f.event.dispatchjquery.min.js:3
                f.event.add.h.handle.i

何か案が?

4

2 に答える 2

1

あなたのコードでは、モデルが定義されていません。これが、アプリケーションが 500 アプリケーション エラーを返す理由についての私の推測です。コメントで前述したように、要素検査ユーティリティを使用して、サーバーが実際に不平を言っていることを把握できます。

[HttpPost]
public ActionResult accountchange(int id, int accountid, bool activate)
{
    // Model = model is most likely undefined
    return Json(new { Model = model, Result = true, Message = "Changed Successfully });
}
于 2012-05-04T22:31:57.220 に答える
0

渡す 3 つのパラメーターを受け入れるように、Global.asax でルーティングを設定しましたか?

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}/{accountId}/{activate}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional, accountId = UrlParameter.Optional, activate = UrlParameter.Optional } 
        );
于 2012-05-04T22:30:08.670 に答える