温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

jquery datatable ajax 获取数据/重新加载

发布时间:2020-06-19 01:47:38 来源:网络 阅读:3180 作者:295631788 栏目:web开发

table

   <table class="table table-striped table-bordered table-hover "  
                                               id="table1">
                    <thead>
                    <tr>
                            <th>名</th>
                            <th>类型</th>
                            <th>是否为空</th>
                            <th>默认值</th>
                            <th>备注</th>
                    </tr>
                    </thead>

                    <tbody>

                    </tbody>

</table>

js

data:
{
"data":[
    {"1":1,
    "2":2,
    "3":3,
    "4":4,
    "5":5,
    },
        {"1":1,
    "2":2,
    "3":3,
    "4":4,
    "5":5,
    }
]
}
                 $.getJSON(url, function (data, textStatus) {

                                        $("#table1").dataTable().fnClearTable();
                    $("#table1").dataTable().fnDestroy();

                    var data1 = data['data']

                    $('#table1').DataTable({
                        data: data1,
                        columns: [
                            {data: '1'},
                            {data: '2'},
                            {data: '3'},
                            {data: '4'},
                            {data: '5'}
                        ],

                        "oLanguage": {
                            "sLengthMenu": "每页显示 _MENU_ 条记录",
                            "sZeroRecords": "对不起,查询不到任何相关数据",
                            "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_条记录",
                            "sInfoEmtpy": "找不到相关数据",
                            "sInfoFiltered": " 数据表中共为 _MAX_ 条记录",
                            "sProcessing": "正在加载中...",
                            "sSearch": "搜索",
                            "oPaginate": {
                                "sFirst": "第一页",
                                "sPrevious": " 上一页 ",
                                "sNext": " 下一页 ",
                                "sLast": " 最后一页 "
                            }
                        },
                        dom: '<"html5buttons"B>lTfgitp,',
                        {#"order": [[0, 'desc']],#}
                        "ordering": false, // 禁止排序
                        buttons: ['copy', 'csv', 'excel']
                    });
                });
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI