这是我的HTML
    <table id="dt">
        <thead>
            <tr>
                <th>make</th>
                <th>model</th>
                <th>serial</th>
                <th>status</th>
                <th>User</th>
                <th>dept</th>
                <th>location</th>
        </thead>
        <tbody>
            
        </tbody>
        <tfoot></tfoot>
    </table>这是我的JS
    <script type="text/javascript" language="javascript" >
         
        $(document).ready(function() {
            
            $.post("json.php",function(data){
                $('#dt').DataTable( {
                    "aaData": data,
                    "aoColumns": [
                            {"mDataProp": "make"},
                            {"mDataProp": "model"},
                            {"mDataProp": "serial"},
                            {"mDataProp": "status"},
                            {"mDataProp": "user"},
                            {"mDataProp": "dept"},
                            {"mDataProp": "location"}
                        ]
                });
            });
    
        } );
    </script>这是json.php
    $data = Array ();
    $data[] = array("make" => "Hp", "model" => "jhbh", "serial" => "kjkhn", "status" => "active", "user" => "John Doe", "dept" => "Manufacturing Services", "location" => "Bindura");
    $data[] = array("make" => "Dell", "model" => "Vostro", "serial" => "kjkhn", "status" => "active", "user" => "Percy Holdin", "dept" => "Manufacturing Services", "location" => "Kwekwe");
    
    echo json_encode($data,JSON_PRETTY_PRINT);我已经对这个问题做了一个编辑,因为现在我想得到动态数据。
错误:
DataTables warning: table id=dt - Requested unknown parameter 'make' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4但是我没有从那个帮助链接中找到有用的东西。
发布于 2017-10-11 08:01:19
您的数据如下所示:
{
  "data": [
    [
      "Hp",
      "jhbh",
      "kjkhn",
      "active",
      "John Doe",
      "Manufacturing Services",
      "Bindura"
    ]
  ]
}https://stackoverflow.com/questions/46682669
复制相似问题