2016-09-04 43 views
0

DataTables.js (Server-side Processing)私のカスタムCMSのために働くようにしようとしていますが、残念ながらデフォルトのサーバーサイドスクリプトは結果を返していません。もちろんDataTables警告:table id = example - 無効なJSON応答です。私はサーバーからの応答がありません

enter image description here

私はそれに私のデータベースの資格情報を入力して、自分のデータベース内の既存のテーブルを選択しました。

私のApacheのログにエラーはありません。

DataTables.jsフォーラムでこの男は、まったく同じ問題が持っていた:

https://datatables.net/forums/discussion/27049/datatables-warning-table-id-example-invalid-json-response-but-no-response-with-server-side-exampl

をしかし、どうやら彼は、サーバーにPDOをインストールすることによってそれを解決しました。私は確認して、私のサーバーはすでにPDOがインストールされています。

編集

尋ねたとして、ここで私が使用していたコードです。私のサーバーでのサンプル・スクリプトへのリンクがhttps://datatables.net/examples/server_side/simple.html

HTML

<table id="example" class="display" cellspacing="0" width="100%"> 
    <thead> 
     <tr> 
      <th>First name</th> 
      <th>Last name</th> 
      <th>Position</th> 
      <th>Office</th> 
     </tr> 
    </thead> 
    <tfoot> 
     <tr> 
      <th>First name</th> 
      <th>Last name</th> 
      <th>Position</th> 
      <th>Office</th> 
     </tr> 
    </tfoot> 
</table> 

はJavaScript

$('#example').DataTable({ 
    "processing": true, 
    "serverSide": true, 
    "ajax": "/server_processing.php" 
}); 

PHPここ

<?php 

/* 
* DataTables example server-side processing script. 
* 
* Please note that this script is intentionally extremely simply to show how 
* server-side processing can be implemented, and probably shouldn't be used as 
* the basis for a large complex system. It is suitable for simple use cases as 
* for learning. 
* 
* See http://datatables.net/usage/server-side for full details on the server- 
* side processing requirements of DataTables. 
* 
* @license MIT - http://datatables.net/license_mit 
*/ 

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* Easy set variables 
*/ 

// DB table to use 
$table = 'node'; 

// Table's primary key 
$primaryKey = 'nid'; 

// Array of database columns which should be read and sent back to DataTables. 
// The `db` parameter represents the column name in the database, while the `dt` 
// parameter represents the DataTables column identifier. In this case simple 
// indexes 
$columns = array(
    array('db' => 'nid', 'dt' => 0), 
    array('db' => 'type', 'dt' => 1), 
    array('db' => 'language', 'dt' => 2), 
    array('db' => 'title',  'dt' => 3), 
); 

// SQL server connection information 
$sql_details = array(
    'user' => '******', 
    'pass' => '******', 
    'db' => '******', 
    'host' => '******' 
); 


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* If you just want to use the basic configuration for DataTables with PHP 
* server-side, there is no need to edit below this line. 
*/ 

require('ssp.class.php'); 

echo json_encode(
    SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns) 
); 

されています。実際にはそこの例とまったく同じです。

http://tests.krown.ch/examples/server_side/simple.html

編集2

私のサーバーは、PDOはそれに取り組んでいます

enter image description here

私もclass_exists('PDO')

で確認証明書が、私はそれらを変更するためならば良いです、私は資格情報が良くない、またはデータベースがfounderではないことを伝える他のいくつかのエラーを取得しますd。

私がテストしていたデータベース内のテーブルは1点である。問題は、ファイルssp.class.phpを持っていないですように見えます

enter image description here

+0

DataTablesの初期化コード、HTMLマークアップ、およびサーバーの応答を表示します。 –

+0

HTML、JavaScript、PHPコードを投稿しました。サーバーの応答はありません。 – 118218

+0

問題はサーバー側のスクリプトにあります。あなたのスクリプトが何の出力も生成しないという手掛かりを得るために、複数のこと、証明書、テーブル名、PHP PDOサポート、PHPまたはWebサーバーエラーログをチェックすることができます。 –

答えて

0

。サーバー側の処理が機能するには、このファイルも必要です。 GIThub hereから入手できます。

あなたは接続先に基づいて修正する必要があるかもしれませんが、あなたの質問にあるものに基づいて、おそらくそのまま動作します。

関連する問題