1

アクション メソッドに 2 つのパラメーターを json として渡すことができません。次の ASP.net MVC3 アクションがあります。

    [HttpPost]
    public JsonResult Create( PatientContactEpisodes patientcontactepisode, IList<PatientContactEpisodeProcedures> patientcontactepisodeprocedures)

そして、私のajax投稿は次のようになります。

     $("#SaveButton")
        .button()
        .click(function () {
            var episode = getpatientcontactepisode();
            $.ajax({
            type: 'POST',
            traditional: true,
            url: "/User/PatientContactEpisodes/Create",
            contentType: 'application/json, charset=utf-8',
            data: {patientcontactepisode: JSON.stringify(episode), patientcontactepisodeprocedures: JSON.stringify(createArray)},
            //data: JSON.stringify(episode),
            dataType: "json",
            success: function (results) {                                                           
                alert("success");
            }
        });
     }); 

問題

問題は、両方のパラメーターをアクションに送信すると、値が渡されないように見えることです。どちらもヌル/空です。一方、単一のパラメーターを送信すると

    //data: JSON.stringify(episode), or //data: JSON.stringify(createarray),

上記は正常に動作します。

4

1 に答える 1

0

試す:

データ: {JSON.stringify({patientcontactepisode: エピソード、patientcontactepisodeprocedures:createArray})}、

これで問題は解決するはずです。

于 2013-02-19T05:00:02.337 に答える