18910140161

javascript-datatables警告:table id=document_table-invalid JSON响应-堆栈溢出

顺晟科技

2022-10-19 13:51:06

235

我试图使用php创建jquery数据表,但收到以下错误:DataTables警告:table id=document_table-invalid JSON响应。

以下是我的代码:

documents.php

<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css">
     <link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap4.min.css">
    <title>Central American Management</title>
  </head>
  <body>
     <div>
         <input type="hidden" id="UserId" name="UserId" data-id="<?php echo($_SESSION['UserId'])?>"></input>
        
        
<div class="container-fluid">
   <div class="row">
      <div class="container">
         <div class="btnAdd">
            <button class="btn btn-primary btn-md" id="add-document"><i class="fa fa-plus " aria-hidden="true">
            </i><span>Add Document</span></button>
            <div class="row">
               <div class="col-md-2"></div>
               <div class="col-md-8"> 
               <table id="document_table" class="table">
                <thead>
                    <tr>
                      <th>ID</th>
                      <th>Name</th>
                      <th>Country</th>
                      <th>Shared</th>
                      <th>Uploaded BY</th>
                      <th>Uploaded Date</th>
                      <th>Options</th>
                     </tr>
                 </thead>
                <tbody>
                </tbody>
               </table>
               </div>
                 <div class="col-md-2"></div>
            </div>
         </div>
      </div>
   </div>
</div>
<div class="modal-container" id="modal-container"></div>
<script src="../javascriptfiles/Documents.js"></script>

 
  </body>
</html>



documents.js

<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css">
     <link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap4.min.css">
    <title>Central American Management</title>
  </head>
  <body>
     <div>
         <input type="hidden" id="UserId" name="UserId" data-id="<?php echo($_SESSION['UserId'])?>"></input>
        
        
<div class="container-fluid">
   <div class="row">
      <div class="container">
         <div class="btnAdd">
            <button class="btn btn-primary btn-md" id="add-document"><i class="fa fa-plus " aria-hidden="true">
            </i><span>Add Document</span></button>
            <div class="row">
               <div class="col-md-2"></div>
               <div class="col-md-8"> 
               <table id="document_table" class="table">
                <thead>
                    <tr>
                      <th>ID</th>
                      <th>Name</th>
                      <th>Country</th>
                      <th>Shared</th>
                      <th>Uploaded BY</th>
                      <th>Uploaded Date</th>
                      <th>Options</th>
                     </tr>
                 </thead>
                <tbody>
                </tbody>
               </table>
               </div>
                 <div class="col-md-2"></div>
            </div>
         </div>
      </div>
   </div>
</div>
<div class="modal-container" id="modal-container"></div>
<script src="../javascriptfiles/Documents.js"></script>

 
  </body>
</html>



服务器端代码

<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css">
     <link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap4.min.css">
    <title>Central American Management</title>
  </head>
  <body>
     <div>
         <input type="hidden" id="UserId" name="UserId" data-id="<?php echo($_SESSION['UserId'])?>"></input>
        
        
<div class="container-fluid">
   <div class="row">
      <div class="container">
         <div class="btnAdd">
            <button class="btn btn-primary btn-md" id="add-document"><i class="fa fa-plus " aria-hidden="true">
            </i><span>Add Document</span></button>
            <div class="row">
               <div class="col-md-2"></div>
               <div class="col-md-8"> 
               <table id="document_table" class="table">
                <thead>
                    <tr>
                      <th>ID</th>
                      <th>Name</th>
                      <th>Country</th>
                      <th>Shared</th>
                      <th>Uploaded BY</th>
                      <th>Uploaded Date</th>
                      <th>Options</th>
                     </tr>
                 </thead>
                <tbody>
                </tbody>
               </table>
               </div>
                 <div class="col-md-2"></div>
            </div>
         </div>
      </div>
   </div>
</div>
<div class="modal-container" id="modal-container"></div>
<script src="../javascriptfiles/Documents.js"></script>

 
  </body>
</html>



我已经研究了一段时间,在做了大量研究后,我仍然不明白这个错误来自哪里。


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航