Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Jquery Ajax PHP实时显示数据表_Php_Jquery_Ajax - Fatal编程技术网

使用Jquery Ajax PHP实时显示数据表

使用Jquery Ajax PHP实时显示数据表,php,jquery,ajax,Php,Jquery,Ajax,我只是想知道如何获取表中数据表的设计。因为筛选器和表的分页不起作用。这是我的密码 我的电脑里有这个插件 <link rel="stylesheet" href="../assets/vendor/datatables-bootstrap/dataTables.bootstrap.css"> <link rel="stylesheet" href="../assets/vendor/datatables-fixedheader/dataTables.fixedHeader

我只是想知道如何获取表中数据表的设计。因为筛选器和表的分页不起作用。这是我的密码

我的电脑里有这个插件

  <link rel="stylesheet" href="../assets/vendor/datatables-bootstrap/dataTables.bootstrap.css">
  <link rel="stylesheet" href="../assets/vendor/datatables-fixedheader/dataTables.fixedHeader.css">
  <link rel="stylesheet" href="../assets/vendor/datatables-responsive/dataTables.responsive.css">
  <link rel="stylesheet" href="../assets/vendor/datatables-bootstrap/dataTables.bootstrap.css">
  <link rel="stylesheet" href="../assets/vendor/datatables-fixedheader/dataTables.fixedHeader.css">
  <link rel="stylesheet" href="../assets/vendor/datatables-responsive/dataTables.responsive.css">

  <script src="../assets/vendor/datatables/jquery.dataTables.min.js"></script>
  <script src="../assets/vendor/datatables-fixedheader/dataTables.fixedHeader.js"></script>
  <script src="../assets/vendor/datatables-bootstrap/dataTables.bootstrap.js"></script>
  <script src="../assets/vendor/datatables-responsive/dataTables.responsive.js"></script>
  <script src="../assets/vendor/datatables-tabletools/dataTables.tableTools.js"></script>
获取的查询:

if(isset($_POST["action"]))
{
 if($_POST["action"] == "fetch")
 {
  $qry = mysql_query("select * from services_type")or die(mysql_error());
  $count = mysql_num_rows($qry);
  $output = '
    <table class="table table-hover dataTable table-striped width-full"  data-plugin="dataTable">
        <thead>
            <th>Services Types</th>
            <th>Action</th>
        </thead>
  ';
  while($row = mysql_fetch_array($qry))
  {
   $services_type_id = $row['services_type_id'];
   $output .= '
    <tbody>
    <tr>
        <td>'.$row['services_type_name'].'</td>
        <td style="text-align:center;">
            <a href="javascript:void(0);" onclick="editServiceType('.$services_type_id.')" data-toggle="modal" class="btn btn-success"><i class="fa fa-edit"></i></a>
        </td>
    </tr>
    </tbody>
   ';
  }
  $output .= '</table>';
  echo $output;
 }
}

我的问题是datatables设计不起作用。谢谢了:

我想出来了。我只是把这个脚本放在 :


检查datatables文档,如果有错误,具体是什么?@yashkumarervma无错误。。它只是数据表。。设计不起作用设计的意思是什么?在$'table\u data'.htmldata;尝试$'table\u data'.dataTable;
    fetch_data();

 function fetch_data()
 {
  var action = "fetch";
  $.ajax({
   url:"table/serviceTypeTable.php",
   method:"POST",
   data:{action:action},
   success:function(data)
   {
    $('#table_data').html(data);
   }
  })
 }
if(isset($_POST["action"]))
{
 if($_POST["action"] == "fetch")
 {
  $qry = mysql_query("select * from services_type")or die(mysql_error());
  $count = mysql_num_rows($qry);
  $output = '
    <table class="table table-hover dataTable table-striped width-full"  data-plugin="dataTable">
        <thead>
            <th>Services Types</th>
            <th>Action</th>
        </thead>
  ';
  while($row = mysql_fetch_array($qry))
  {
   $services_type_id = $row['services_type_id'];
   $output .= '
    <tbody>
    <tr>
        <td>'.$row['services_type_name'].'</td>
        <td style="text-align:center;">
            <a href="javascript:void(0);" onclick="editServiceType('.$services_type_id.')" data-toggle="modal" class="btn btn-success"><i class="fa fa-edit"></i></a>
        </td>
    </tr>
    </tbody>
   ';
  }
  $output .= '</table>';
  echo $output;
 }
}
<script>
   $("#table").dataTable({
   });
</script>