我正在尝试使用JQuery Datatables 1.10.5实现服务器端处理。这是我的DataTable代码
$('#userTable').dataTable({
serverSide: true,
ajax: {
type: "POST",
data: {
'statusFilter': $('#status-filter').val(),
'secondaryFilterOption': $('#secondary-filter-option').val(),
'secondaryFilterOperator': $('#secondary-filter-operator').val(),
'secondaryFilterText': $('#secondary-filter-text').val()
},
url: "UserManagement.aspx/GetUsers",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert("success");
},
error: function (jqXhr, textStatus, errorThrown) {
alert(jqXhr.responseText);
}
},
scrollY: "500px",
scrollCollapse: true,
columnDefs: [
{
"targets": [0],
"visible": false,
"searchable": false
},
{
"targets": [8],
"visible": true,
"searchable": false,
"render": function (data, type, row, meta) {
return '<img title="Edit" class="action-button edit-user center" src="/ntims/images/icon_edit.gif" id="' + row.id + '" />';
},
}],
columns: [
{ "data": "id" },
{ "data": "lastName" },
{ "data": "firstName" },
{ "data": "login" },
{ "data": "command" },
{ "data": "email" },
{ "data": "phone" },
{ "data": "status" }
]
});
我在ajax调用期间收到以下错误:
{"Message":"Invalid JSON primitive: draw.","StackTrace":" at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}
&#34;绘制&#34;是数据表发送到服务器的东西。我无法控制这个变量对我的知识。我看过Jquery论坛并做了一些其他研究,但我无法解决这个问题。我见过人们对他们发送的其他参数有疑问,但是&#34; draw&#34;是Jquery发送的东西,而不是我。
答案 0 :(得分:0)
你可以给&#34; bServerSide&#34; :对于serverSide为true:true。 如果它不起作用,请检查&#34; serverSide&#34;:true