单击DataTable PHP中的分页时,正在加载同一页面

时间:2018-11-13 05:31:27

标签: php jquery datatables

当我单击DataTable中的页码时,它不会移动到下一页,而是会再次加载整个页面。

但是,如果我单击DataTable排序按钮,然后再次单击分页页码,则DataTable可以正常工作。谁能帮我解决这个问题。预先感谢。

<?php include 'header.php'; ?>
</style>
  <!-- Breadcrumbs -->
  <section class="bg-gray-7">
    <div class="breadcrumbs-custom box-transform-wrap context-dark">
      <div class="container">
        <h3 class="breadcrumbs-custom-title">Sailing Schedules</h3>
        <div class="breadcrumbs-custom-decor"></div>
      </div>
      <div class="box-transform" style="background-image: url(images/bg-typography.jpg);"></div>
    </div>
    <div class="container">
      <ul class="breadcrumbs-custom-path">
        <li><a href="index.php">Home</a></li>
        <li class="active">Sailing Schedule</li>
      </ul>
    </div>
  </section>

<br>
<br>
<div class="container">

<?php
  ini_set('display_errors', 1);
  error_reporting(E_ALL);

  // Include config file
  require 'config.php';

  $sql = "SELECT * FROM long_sched";
  if($result = mysqli_query($con, $sql)){
    if(mysqli_num_rows($result) > 0){
      echo "<table class='table-custom table-custom-primary' id ='long_schd_table'>";
      echo "<thead>";
      echo "<tr>";
      echo "<th>Service Name</th>";
      echo "<th>Description</th>";
      echo "</tr>";
      echo "</thead>";
      echo "<tbody>";

      while($row = mysqli_fetch_array($result)){
        echo "<tr>";
        echo "<td><a href=http://localhost/permatest/". $row['long_filepath'] . " target='_self' download>".$row['long_service']."</a></td>";
        echo "<td>" . $row['long_desc'] . "</td>";
        echo "</tr>";
      }
      echo "</tbody>";                            
      echo "</table>";
      // Free result set
      mysqli_free_result($result);
    } else {
      echo "<p class='lead'><em>No records were found.</em></p>";
    } else {
      echo "ERROR: Could not able to execute ".$sql." " . mysqli_error($con);
    }
    // Close connection
    mysqli_close($con);
?>

</div>
</section>
<br>
<br>

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

<script>
  $('#long_schd_table').DataTable({});
</script>

上面的代码给出了此错误,但是在我的控制台中我没有得到任何错误信息。

0 个答案:

没有答案