DataTables无效的JSON响应错误

时间:2017-08-09 18:43:20

标签: php mysql json datatables

我正在尝试学习如何使用DataTable在我的网站上实现它。首先,我使用https://editor.datatables.net/generator/生成模板,下载它然后启动xampp,启动apache和mysql并将模板放在那里。现在我刚刚启动了index.html发电机输出,我得到了“

  

DataTables警告:table id = Publications - 无效的JSON响应。有关此错误的详细信息,请参阅http://datatables.net/tn/1

我按照说明操作,这是错误:

  

致命错误:未捕获异常:发生SQL错误:       SQLSTATE [3D000]:无效的目录名称:1046未选择数据库       C:\ XAMPP \ htdocs中\ DataTablesEditor \ PHP \ lib中\数据库\驱动\ Mysql的\ Query.php:108       堆栈跟踪:       #0 C:\ xampp \ htdocs \ DataTablesEditor \ php \ lib \ Database \ Query.php(950):       数据表\数据库\ DriverMysqlQuery-> _exec()       #1 C:\ xampp \ htdocs \ DataTablesEditor \ php \ lib \ Database \ Query.php(292):       DataTables \ Database \ Query-> _raw('CREATE TABLE IF ...')       #2 C:\ xampp \ htdocs \ DataTablesEditor \ php \ lib \ Database \ Database.php(394):       DataTables \ Database \ Query-> exec('CREATE TABLE IF ...')       #3 C:\ xampp \ htdocs \ DataTablesEditor \ php \ table.Publications.php(24):       DataTables \ Database-> sql('CREATE TABLE IF ...')       #4 {main}         扔进了     C:\ xampp \ htdocs \ DataTablesEditor \ php \ lib \ Database \ Driver \ Mysql \ Query.php 108

任何解决方案?

的config.php     

/* 
* DB connection script for Editor
* Created by http://editor.datatables.net/generator
*/

// Enable error reporting for debugging (remove for production)
error_reporting(E_ALL);
ini_set('display_errors', '1');

/*
* Edit the following with your database connection options
*/
$sql_details = array(
"type" => "Mysql",
"user" => "",
"pass" => "",
"host" => "",
"port" => "",
"db"   => "",
"dsn"  => "charset=utf8"
);

的index.html

<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <title>DataTables Editor - Publications</title>

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs-3.3.7/jq-2.2.4/pdfmake-0.1.27/dt-1.10.15/b-1.3.1/b-html5-1.3.1/b-print-1.3.1/r-2.1.1/se-1.2.2/datatables.min.css">
    <link rel="stylesheet" type="text/css" href="css/generator-base.css">
    <link rel="stylesheet" type="text/css" href="css/editor.bootstrap.min.css">

    <script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/v/bs-3.3.7/jq-2.2.4/pdfmake-0.1.27/dt-1.10.15/b-1.3.1/b-html5-1.3.1/b-print-1.3.1/r-2.1.1/se-1.2.2/datatables.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/dataTables.editor.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/editor.bootstrap.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/table.Publications.js"></script>
</head>
<body class="bootstrap">
    <div class="container">

        <h1>
            DataTables Editor <span>Publications</span>
        </h1>

        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="Publications" width="100%">
            <thead>
                <tr>
                    <th>test1</th>
                    <th>test2</th>
                    <th>test3</th>
                </tr>
               </thead>
            </table>

        </div>
    </body>
</html>

enter image description here

0 个答案:

没有答案