【问题标题】:How can i add AJAX response Success JSON data to jQuery Datatable?如何将 AJAX 响应成功 JSON 数据添加到 jQuery Datatable?
【发布时间】:2018-02-06 08:24:46
【问题描述】:

我想将 JSON 数据添加到我从 AJAX 发布响应中获得的数据表中,但我的流程无法正常工作,任何人都可以提出任何建议吗?

我的 ajax 代码:

$.ajax({
    method: "POST",  
    url: "Controller",  
    cache: false,
    data: { ReqAction: "getALLUserData" }, 
    success: function(data) {
        return data;                
    }
});

作为 AJAX 响应,我得到的是:

[{
    "user_code":1,
    "user_ref_number":"100809",
    "user_grp_code":2,
    "user_name":"ememhasan",
    "user_pass":"pass123",
},
{
    "user_code":1,
    "user_ref_number":"100809",
    "user_grp_code":2,
    "user_name":"ememhasan",
    "user_pass":"pass123",
},
{ more ....}
]

那么我如何将它用于我的数据表?

提前致谢。

【问题讨论】:

标签: jquery json ajax datatable datatables


【解决方案1】:

dataSrc 属性是,您正在寻找。

dataSrc: function ( json ) {
           return json.data;
         }   

这绝对会帮助你

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 2018-06-08
    • 2014-04-30
    • 2019-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多