jquery - jquery自动完成选择事件,显示动作数据
问题描述
在选择事件自动完成时,我想在我的控制器中调用 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 事件上调用我的操作并用数据填充视图
推荐阅读
- angular - 如何在 Angular 7+ 中从 url 捕获 id 和 token
- html - 将 app-root 中的 gif 中心与 Angular 中的中心对齐
- javascript - HTML Javascript:如何验证信息并单击将用户登录到另一个页面(他们的主页)?
- sql-server - 从字符串转换日期和/或时间时转换失败 - 不知道为什么?
- python - 从文件构建二叉搜索树
- ios - 无法呈现框架内的 viewController
- php - 我无法将数据插入数据库 mariadb 并且没有错误消息
- docker - 同一网络中的容器无法通信
- python - 如何解析此日志以获取使用 Python3 进行绘图的日期/超时
- java - 从日历周信息创建 LocalDate