asp.net-mvc-5之jquery 数据表 ajax 数据源问题
thcjp
阅读:41
2025-06-02 22:19:02
评论:0
我按照数据表网站上显示的示例发出了 ajax 请求,但我无法让它与数据表 nuget 包一起使用。模型绑定(bind)器很生气,因为搜索值为 null 并期望它是一个空字符串。
Controller :
public JsonResult ListUsers([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest request)
查看:
<table id="users-table" class="table table-hover table-striped">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
</thead>
</table>
$(function() {
$('#users-table').dataTable({
ajax: '@Url.Action("ListUsers", "Businesses",null,Request.Url.Scheme)'
});
});
搜索的值不能为空。如果没有执行搜索,请提供一个空字符串。 参数名称:值
请您参考如下方法:
如果您使用服务器端处理,则需要添加 'serverSide': true 作为 DataTables 参数,请参见下面的代码:
$('#users-table').dataTable({
'serverSide': true,
'ajax': '@Url.Action("ListUsers", "Businesses",null,Request.Url.Scheme)'
});
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。



