-1

ajax を介してコントローラーのアクションにオブジェクトを送信しましたが、コントローラーでオブジェクトを受信する方法がわかりません。私のajax呼び出しは次のとおりです。

       $.ajax({
            type: "POST",
            url: '@Url.Action("Create","Home")',
            data: { ID: '@Model.ID', Name: '@Model.Name'}
        }).done(function (msg) {
            alert("Added :" + msg);
        });

これはうまくいくはずですが、コントローラーでオブジェクトを受け取る方法がわかりません。私はこれを書きました:

    public ActionResult Create(Home h)
    {

    }

しかし、それは機能していません。これについて助けが必要です。よろしくお願いします。

私のホームクラス:

public class Home
{
    public int ID { get; set; }
    public string Name { get; set; }
}
4

1 に答える 1

0

あなたの行動は次のようになります:

[HttpPost]
public ActionResult Create(Home h)
{
    throw new NotImplementedException(); // put you code here
}
于 2013-06-27T09:29:32.627 に答える