jQuery数据表错误:无效的JSON原语:绘制 [英] Jquery Datatables Error: Invalid JSON primitive: draw

查看:109
本文介绍了jQuery数据表错误:无效的JSON原语:绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JQuery Datatables 1.10.5实现服务器端处理.这是我的DataTable代码

I am trying to implement server side processing with JQuery Datatables 1.10.5. Here is my code for the 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调用期间出现以下错误:

I get the following error during the ajax call:

{"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"}

绘制"是数据表发送到服务器的东西.我无法控制此变量.我看过Jquery论坛并进行了其他一些研究,但是我无法弄清楚这个问题.我已经看到人们对他们正在发送的其他参数有疑问,但是"draw"是Jquery发送的东西,而不是我.

"draw" is something that datatables sends to the server. I have no control over this variable to my knowleged. I have looked at the Jquery Forums and did some other research but I cannot firgure out this issue. I have seen people have issues about other parameters that THEY are sending, but "draw" is something Jquery sends, not me.

推荐答案

您可以为serverSide指定"bServerSide":true:true. 如果不起作用,请检查"serverSide":true

You can give "bServerSide" : true for serverSide: true. If it doesnt work check with "serverSide": true

这篇关于jQuery数据表错误:无效的JSON原语:绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆