通过 AJAX 刷新所有 dataTable 页面成为一个页面

我以某种方式设法实现了它,不幸的是客户端数据表在刷新时被破坏了。


通过销毁,dataTable 中的所有数据都在一个页面中。


这是桌子。


<table id="earnings_amendment_account" class="table table-bordered" style="table-layout: fixed; display: none">

                <thead>

                <th></th>

                  <th>Account Code</th>

                  <th>Account Title</th>

                  <th>Account Type</th>

                  <th>Tools</th>

                </thead>

<tbody id="table-body">

 <?php include 'tableBody.php';?>

                </tbody>

              </table>

这是 tableBody.php


<?php include 'backend/conn.php'; ?>                 

                 <?php

                    $params=array();

                    $sql = "SELECT accountcode,accounttype,accounttitle,accounttype,postedby,dateposted,approvedby,dateapproved FROM earningsamendmentaccount";

$query = sqlsrv_query($conn, $sql, $params, array("Scrollable" => SQLSRV_CURSOR_KEYSET));

if ($query === false ) { echo "Error (sqlsrv_query): ".print_r(sqlsrv_errors(), true); exit; } 


                    while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){


                      echo "

                      <tr data-key-1='".$row['postedby']."' data-key-2='".$row['dateposted']."' data-key-3='".$row['approvedby']."' data-key-4='".$row['dateapproved']."'>

                        <td class='details-control'></td>

                        <td>".$row['accountcode']."</td>

                          <td>".$row['accounttitle']."</td>

                          <td>".$row['accounttype']."</td>

                          <td>

有没有办法解决这个问题?


MMMHUHU
浏览 217回答 1
1回答

慕森卡

尝试使用您的数据表对象&nbsp;var earnings_amendment_account_table = $('#earnings_amendment_account').DataTable({});所以在你的jQuery/AJAX - (earnings_amendment_account.php)更改$("#earnings_amendment_account").DataTable().ajax.reload();为earnings_amendment_account_table.ajax.reload();
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript