亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

數據表不適用于ajax加載的表

數據表不適用于ajax加載的表

PHP
青春有我 2023-12-15 14:58:34
我在一個名為values.php的文件中有一個表,我通過ajax從index.php調用這個文件,在索引中我有數據表腳本,我在索引中編寫的示例表可以工作,但是通過ajax加載的同一個表沒有 39;不工作。有什么問題嗎?基本項目代碼function call_table() {    var xhttp = new XMLHttpRequest();    xhttp.onreadystatechange = function() {        if (this.readyState == 4 && this.status == 200) {            document.getElementById("content").innerHTML = this.responseText;        }    };    xhttp.open("GET", "values.php", true);    xhttp.send();}call_table();PHP 值.php$data='    <div class="table-responsive">        <table id="sorting-table" class="table mb-0">            <thead>                <tr>                    <th>Order ID</th>                    <th>Customer Name</th>                    <th>Country</th>                    <th>Ship Date</th>                    <th><span style="width:100px;">Status</span></th>                    <th>Order Total</th>                    <th>Actions</th>                </tr>            </thead>            <tbody>                <tr>                    <td><span class="text-primary">054-01-FR</span></td>                    <td>Lori Baker</td>                    <td>US</td>                    <td>10/21/2017</td>                    <td><span style="width:100px;"><span class="badge-text badge-text-small info">Paid</span></span></td>                    <td>$139.45</td>                    <td class="td-actions">                        <a href="#"><i class="la la-edit edit"></i></a>                        <a href="#"><i class="la la-close delete"></i></a>                    </td>                </tr>                <tr>echo $data;
查看完整描述

1 回答

?
慕仙森

TA貢獻1827條經驗 獲得超8個贊

僅在渲染表格后將初始化代碼放入ajax代碼中


function call_table() {

    var xhttp = new XMLHttpRequest();

    xhttp.onreadystatechange = function() {

        if (this.readyState == 4 && this.status == 200) {

            document.getElementById("content").innerHTML = this.responseText;

            $('#sorting-table').DataTable();        //here

        }

    };

    xhttp.open("GET", "values.php", true);

    xhttp.send();

}

call_table()

;


查看完整回答
反對 回復 2023-12-15
  • 1 回答
  • 0 關注
  • 189 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號