如何解决ASP MVC javascript
我正在尝试按名称 fitlra,结果,我通过 jquery 刷新了表,但我不知道为什么它会重新加载页面的 HTML 并复制 HTML。我留下我的代码和照片。
我的控制器
public ActionResult About(prueba1 model)
{
if (model.Nombre != null)
{
Dbcon.Conexion con = new Dbcon.Conexion();
sqlParameter[] arrParam = new sqlParameter[1];
arrParam[0] = new sqlParameter("@nombre",model.Nombre);
arrParam[0].DbType = DbType.String;
arrParam[0].Direction = ParameterDirection.Input;
return View(con.Tablin2(arrParam).ToList());
}
else
{
Dbcon.Conexion con = new Dbcon.Conexion();
return View(con.Tablin().ToList());
}
}
我的观点和我的 javascript
<div class="row">
<table id="tablen">
<thead>
<tr>
<th>Periodo</th>
<th>Nombre</th>
<th>Edad</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<th>@item.periodo</th>
<th>@item.Nombre</th>
<th>@item.edad</th>
</tr>
}
</tbody>
</table>
</div>
@section Scripts{
<script src="~/Scripts/jquery-3.4.1.js"></script>
<script src="~/Scripts/jquery-3.4.1.min.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<script type="text/javascript">
}
$(function ()
{
$("#buscador").click(function ()
{
var nombre = $("#nombre").val();
if (nombre == null || nombre == "") {
alert("Cuidado");
return;
}
// probar que valor console.log(cuenta);
var dataToPost = {};
dataToPost.nombre = nombre;
$.post("@Url.Action("About","Home")",{ model: dataToPost },function (data) {
$("#tablen").html(data);
$("#tablen").show();
});
});
});
请帮帮我
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。