问题描述
我正在尝试按名称 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 (将#修改为@)