在我的项目中,我在同一页面上有多个表单,我想一次性传递给控制器。如何做到这一点?
<script>
function onSaveButtonClicked() {
var form = $("#SaveForm").serialize();
var form2 = $("#SaveForm").serialize();
$.ajax({
url: '@Url.Action("Filter","SearcherEngine")',
type: 'post',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify({ model: form, model2: form2 }),
cache: false,
success: function (result) {
alert(result);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError);
}
});
};
[HttpPost]
public ActionResult Filter(MyViewMOdel model,MyViewModel2 model2)
{
}