0

mvc 形式のデータ テーブルを作成します。しかし、スクリプトをロードすると、テーブルのデータと一致せず、テーブルの行にバインドされません。私のコードを以下に示します。

$.ajax({ 
    // my passing value
    success: function (data) { // i get the data properly 
        $('#Table').dataTable().fnClearTable();
        $.each(data, function (k, v) {
            var ID= v.ID;
            var name= v.name;
            var batch= v.batch;

            $('#Table').dataTable().fnAddData([
                ID,
                name,
                batch
            ]);
        });
    }
});

私のテーブル:

<table id="Table" width="100%">
    <thead>
        <tr>
            <th>EMP_ID</th>
            <th>EMP_name</th>
            <th>EMP_batch</th>
        </tr>
    </thead>
    <tbody></tbody>
</table>

データテーブル: http://www.datatables.net/

4

1 に答える 1