weixin_33709364 2016-06-15 01:42 采纳率: 0%
浏览 9

每页显示2个表格

I have 2 grid-tables on my page. When I want to load them both, the first grid-table gets loaded, but the second is not. How can I fix this?

Here is the table for my first grid-table:

<table id="employee_grid" class="display" width="100%" cellspacing="0">
    <thead>
        <tr>
            <th>Number</th>
            <th>Name</th>
        </tr>
    </thead>
</table>

There is the second grid table:

<table id="employee_grid2" class="display" width="100%" cellspacing="0">
    <thead>
        <tr>
            <th>Number</th>
            <th>Name</th>
        </tr>
    </thead>
</table>

As you can see I changed the ID for the second table.

There is the javascript for the first table:

<script type="text/javascript">
    $(document).ready(function() {
        $('#employee_grid').DataTable({
            "bprocessing" : true,
            "serverSide" : true,
            "ajax" : {
                "url" : "post1.php",
                "type" : "POST",
                "error" : function() {
                    $("#employee_grid_processing").css("display", "none");
                }
            },
            "columnDefs" : [{
                "targets" : 0,
                "render" : function(data, type, full, meta) {
                    return '<a href="http://www.example.com/' + data + '">Link</a>';
                }
            }]
        });
    });
</script>

Here is the javascript for the second table:

<script type="text/javascript">
    $(document).ready(function() {
        $('#employee_grid2').DataTable({
            "bprocessing" : true,
            "serverSide" : true,
            "ajax" : {
                "url" : "post2.php",
                "type" : "POST",
                "error" : function() {
                    $("#employee_grid_processing").css("display", "none");
                }
            },
            "columnDefs" : [{
                "targets" : 0,
                "render" : function(data, type, full, meta) {
                    return '<a href="http://www.example.com/' + data + '">Link</a>';
                }
            }]
        });
    });
</script>

As you can see, also the only thing I changed in the second javascript code = #employee_grid2. I think this should be enough to run both javascript codes on 1 page, but the second table dont gets filled.

How can I fix this?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛