我无法将2个参数作为json传递给action方法。我有以下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),
以上工作正常。
答案 0 :(得分:0)
尝试:
数据:{JSON.stringify({patientcontactepisode:episode,patientcontactepisodeprocedures:createArray})},
这应该适合你。