0
私は、このマニュアルに従って、サーバー側の処理のDataTableを作成しようとしました:サーバーサイドの処理データテーブルはどのように作成できますか?
https://datatables.net/examples/server_side/simple.html
しかし、私は私のデータベースから任意の結果を得ることはありません。
のindex.php:
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css">
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>id</th>
</tr>
</thead>
<tfoot>
<tr>
<th>id</th>
</tr>
</tfoot>
</table>
<script>
$(document).ready(function() {
$('#example').DataTable({
"processing": true,
"serverSide": true,
"ajax": "server.php"
});
});
</script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
server.phpという:
<?php
// DB table to use
$table = 'elephants';
// Table's primary key
$primaryKey = 'id';
// 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' => 'id', 'dt' => 0),
);
// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => 'root',
'db' => 'animals',
'host' => 'localhost'
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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)
);
とssp.class.php:私は知りません
https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/ssp.class.php
、どのようなI間違っていましたが、結果は
ですあなたが依存JSライブラリを追加する前に、あなたのコードを初期化しているID
ID
私はあなたが提案し、まさにテストが、残念ながら、私は私の更新asnwerを試してみてください@Jarlaどんな結果 – Jarla
を得ることはありません、あなたはjQueryとDataTableのファイルを追加する前にJSを初期化しています。 –
ああ!今度はデータテーブルがロードされます!しかし、私はまだ 'DataTables警告:table id = example - Ajaxエラーです。このエラーの詳細については、http:// datatables.net/tn/7'を参照してください。 – Jarla