使用Ajax调用Web服务的数据表

时间:2018-11-15 03:59:34

标签: ajax web-services datatables

我是数据表的新手,并且一直呆在这里。我想将此记录显示为来自Web服务的数据表。

html代码:

    <table class="table table-hover display" id="tbl_Account" style="width:100%">
        <thead>
            <tr>
                <th>Id</th>
                <th>UserName</th>
                <th>DisplayName</th>
                <th>Address</th>
                <th>ExtensionNumber</th>
                <th>Salary</th>
                <th>ExtraInfo</th>
            </tr>
        </thead>
    </table>

javascript:

$('#tbl_Account').DataTable({
    responsive: true,
    processing: true,
    serverSide: true,
    ajax: {
        type: "POST",
        url: "/WebServices/WSAccount.asmx/getList_Account",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        //data: {} 
        //no parameter in web service 
    },
    columns: [
        { "data": "Id" },
        { "data": "UserName" },
        { "data": "DisplayName" },
        { "data": "Address" },
        { "data": "ExtensionNumber" },
        { "data": "Salary" },
        { "data": "ExtraInfo" }
    ]
});

错误:

"Message":"Invalid JSON primitive: draw."

抱歉,我的英语不好。谁能帮我吗?

0 个答案:

没有答案