Jquery 从datatables中的webservice设置Json数据

Jquery 从datatables中的webservice设置Json数据,jquery,json,api,web-services,datatables,Jquery,Json,Api,Web Services,Datatables,我必须将从Web服务返回的数据设置为datatable HTML表。给出了程序代码。我曾尝试设置列,但在显示“表中没有可用数据”时,这不起作用 HTML <table id="example" cellspacing="0" width="100"> <thead class="scrollmenu"> <tr>

我必须将从Web服务返回的数据设置为datatable HTML表。给出了程序代码。我曾尝试设置列,但在显示“表中没有可用数据”时,这不起作用

HTML

     <table id="example" cellspacing="0" width="100">
                    <thead class="scrollmenu">
                        <tr>
                            <th>Sr.#</th>
                            <th>Reference</th>
                            <th>Type</th>
                            <th>Value Date</th>
                            <th>Amount</th>
                            <th>Transaction Type</th>
                            <th>Sender Bic</th>
                            <th>Receiver Bic</th>
                            <th>Receiver Account</th>
                            <th>Sender Account</th>
                            <th>Sender</th>
                            <th>Receiver</th>
                            <th>Payer's Participant</th>
                            <th>Beneficiary Participant</th>
                            <th>Creation Date</th>
                        </tr>
                    </thead>


                    <tbody>
                    </tbody>
                </table>

但这是行不通的。我尝试了不同的选择,但都没能成功。需要帮助。

您需要使用选项将数据传递到DataTable


您需要调试对
仪表板/fetchDataDetails
var datefrom = $('#dateFrom').val();
    var dateto = $('#dateTo').val();
    $.ajax({
        type: "POST",
        url: "/DashBoard/fetchDataDetails?flag="+flag+"&from=" + datefrom + "&" + "to=" + dateto,
         contentType: "application/json; charset=utf-8",
        success: function (data) {
            debugger;
            if (data.length > 0) {
                debugger;
                var abc = data;
                $('#example').DataTable({
                    "paging": true,
                    "ordering": true,
                    "info": true,
                    "columns": [
                        { "data": "system_reference_no" },
                        { "data": "mt_type" },
                        { "data": "system_refdate" },
                        { "data": "system_refamount" },
                        { "data": "TransType_Code" },
                        { "data": "sender" },
                        { "data": "receiver" },
                        { "data": "receiver_account" },
                        { "data": "sender_account" },
                        { "data": "sender_bic" },
                        { "data": "receiver_bic" },
                        { "data": "sender_bank" },
                        { "data": "receiver_bank" },
                        { "data": "creation_date" },
                    ]
                });

            }
            //  processingGif(false);
        },
        error: function (data) {
            // processingGif(false);
        }



    });
$('#example').DataTable({
   // ... skipped ...
   "data": data 
});