在选择事件自动完成时,我想在我的控制器中调用一个JsonResult动作来显示数据库中的数据。
函数JS
select: function (e, i) {
$("#idp").val(i.item.val);
$.ajax({
type: 'Post',
dataType: "json",
contentType: "application/json; charset=utf-8",
url: '/controller/action/',
data: "{ 'id': '" + i.item.val + "'}",
success: function (data) {
// code to put here//
$("#mydiv").html(data);
}
})
},
我的动作
public ActionResult ListObject(int? idpatient)
{
return PartialView(MyList);
}
我的看法
@model IEnumerable<MyProject.Models.Object> table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.IdNumber)
</th>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.Date)
</th>
<th>
@Html.DisplayNameFor(model => model.Phone)
</th>
<th>
Actions
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.IdNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@Html.DisplayFor(modelItem => item.Phone)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}
我有一个自动完成的文件,我想在slect事件,调用我的行动,并填补了数据的看法。