来自PHP脚本的活动表上的jQuery DataTables

来自PHP脚本的活动表上的jQuery DataTables,php,jquery,datatables,html-table,live,Php,Jquery,Datatables,Html Table,Live,我在实现simple时遇到了问题,我无法使它在PHP脚本返回的表中工作。假设这个名为simple_table.PHP的简单PHP脚本: <?php echo ' <table class="table_type"> <thead> <tr> <th>Column 1</th> <th>Column 2

我在实现simple时遇到了问题,我无法使它在PHP脚本返回的表中工作。假设这个名为simple_table.PHP的简单PHP脚本:

<?php
    echo '
    <table class="table_type">
        <thead>
            <tr>
                <th>Column 1</th>
                <th>Column 2</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Row 1 Data 1</td>
                <td>Row 1 Data 2</td>
            </tr>
            <tr>
                <td>Row 2 Data 1</td>
                <td>Row 2 Data 2</td>
            </tr>
        </tbody>
    </table>';
?>
要使这个简单的示例工作并保持简单,需要做些什么?问题是,对于这个由如此简单的脚本生成的动态表的有用场景,没有解决方案


嗯,也许你必须有一个预先存在的
,只有你才能填充相应的

问题是因为你在页面拥有元素
表之前运行
.dataTable()
。加载页面时,您不需要调用
.dataTable()
,而需要在将表添加到
中后运行它


谢谢,过了一会儿我才意识到这一点。谢谢。get('simple_table.php',{},function(html_table){content.html(html_table);$('table.table_type')。dataTable({bRetrieve:true});})。。。
$(document).ready( function () {
    $('table.table_type').dataTable();
} );

$('div.push_button li').click(function() {
    var content = $(this).closest('div').children('div.content');
    $.get('simple_table.php', {}, function(html_table) {
            content.html(html_table);
    } );
} );
$('div.push_button li').click(function() {
    var content = $(this).closest('div').children('div.content');
    $.get('simple_table.php', {}, function(html_table) {
            content.html(html_table);
            content.find('table').dataTable();
    } );
} );