其他分享
首页 > 其他分享> > datatables无法加载数据

datatables无法加载数据

作者:互联网

服务器返回的json 数据,地址:http://www.mikrokosmos.top/findGuard2?carStatus=1&carStatus2=1

[{“car_check”:null,“name”:null,“entryTime”:null,“end”:null,“supplier”:null,“typeCar”:null,“carisworry”:null,“carNum”:“123”,“carCompanyId”:null,“carCompany”:“中外运”,“cardId”:null,“carType”:null,“phone”:null,“factoryTime”:null,“orderId”:null,“packageNum”:null,“carTypeId”:null,“quantity”:null,“packageType”:null,“orderBegin”:null,“orderEnd”:null,“supplierId”:null,“packageTypeId”:null,“doneType”:null,“orderStatus”:null,“typeCarName”:“送货车”,“carStatus”:null,“carStatus2”:1,“begin”:null,“ponum”:null,“timelong”:null,“express”:null,“registrationTime”:null,“carId”:2},{“car_check”:null,“name”:“liuc”,“entryTime”:null,“end”:null,“supplier”:null,“typeCar”:null,“carisworry”:null,“carNum”:“jin111111”,“carCompanyId”:null,“carCompany”:“中外运”,“cardId”:“320333333333333333”,“carType”:“卡车”,“phone”:“13333333333”,“factoryTime”:null,“orderId”:null,“packageNum”:null,“carTypeId”:null,“quantity”:null,“packageType”:null,“orderBegin”:null,“orderEnd”:null,“supplierId”:null,“packageTypeId”:null,“doneType”:null,“orderStatus”:null,“typeCarName”:“送货车”,“carStatus”:null,“carStatus2”:1,“begin”:null,“ponum”:null,“timelong”:null,“express”:null,“registrationTime”:“2020-12-17 23:47:01.0”,“carId”:1}]

datatable处理


  

```javascript
  //datatable汉化
    $('#enterTab').DataTable({
        ajax: {
            url: "/findGuard2",
            data: {
                "carStatus": 1,
                "carStatus2": 1
            },
            dataSrc: ''
        },
        columns: [
            {data: "name"},
            {data: "carNum"},
            {data: "cardId"},
            {
                data: "registrationTime", "render": function (data) {

                    data = data.substring(0, data.lastIndexOf('.'));
                    return data;
                }
            },
            {
                data: "carId", "render": function (data) {
                    var buttons = "<td class='EnterBtn'> <input type='hidden' class='carId' value='" + data + "'></td>" + " <button" +
                        " type='button' class='enterCar btn btn-success'>进入</button>" + "<button type='button'" +
                        " class='riviseCar btn btn-warning'>修改</button>"

                    return buttons;
                }
            }

        ],

        language: {
            "sProcessing": "处理中...",
            "sLengthMenu": "显示 _MENU_ 项结果",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
            "sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        }
    });

无法加载返回的json 数据

标签:datatables,carStatus2,name,registrationTime,无法,carStatus,null,data,加载
来源: https://blog.csdn.net/Liucccccccc/article/details/115298789