我有一个看法
@using staffInfoDetails.Models
@model staffInfo
<link href="../../Content/myOwn.css" rel="stylesheet" type="text/css" />
@{staffInfo stf = Model;
}
<div id="education1">
@using (Html.BeginForm("addNewEdu","Home",FormMethod.Post))
{
@Html.HiddenFor(x=>x.StaffId)
<table>
<tr>
<th>Country</th>
<th>Board</th>
<th>Level</th>
<th>PassedYear</th>
<th>Division</th>
</tr>
<tr>
@Html.EditorFor(x => x.eduList)
</tr>
<tr>
@*<td><input type="submit" value="create Another" id="addedu"/> </td>*@
@*<td>@Html.ActionLink("Add New", "addNewEdu", new { Model })</td>*@
</tr>
</table>
}
<button id="addedu">Add Another</button>
</div>
我想使用 jquery 将模型 staffInfo 传递给控制器,如下所示
<script type="text/javascript">
$(document).ready(function () {
$("#addedu").live('click', function (e) {
// e.preventDefault();
$.ajax({
url: "Home/addNewEdu",
type: "Post",
data: { model: stf },//pass model
success: function (fk) {
// alert("value passed");
$("#education").html(fk);
}
});
});
});
</script>
jquery 似乎只传递元素而不是整个模型,所以我如何将模型从视图传递到控制器,这样我就不必在 jquery 中编写整个参数列表