Bonjour,
J'utilise Datatable pour créer un tableau de données pour le travail. Or je rencontre cette erreur :
DataTables warning: table id=example - Ajax error. For more information about this error, please see http://datatables.net/tn/7
Je vous joins les importations sur mon html :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css"> <script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script> <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> <script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
Ainsi que le script utilisé :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <script type="text/javascript"> $(document).ready(function() { $('#example').DataTable( { "processing": true, "serverSide": true, "ajax": "scripts/server_processing.php" } ); } ); </script>
Et mon fichier server_side.php :
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 <?php $table = 'matable_tel'; $primaryKey = 'id'; $columns = array( array( 'db' => 'id','dt' => 0 ), array( 'db' => 'direction','dt' => 1 ), array( 'db' => 'service','dt' => 2 ), array( 'db' => 'fonction','dt' => 3 ), array( 'db' => 'attribution','dt' => 4 ), array( 'db' => 'numero', 'dt' => 5 ), array( 'db' => 'materiel', 'dt' => 6 ), array( 'db' => 'forfait', 'dt' => 7 ), array( 'db' => 'options', 'dt' => 8 ), array( 'db' => 'date_debut', 'dt' => 9, 'formatter' => function( $d, $row ) { return date( 'jS M y', strtotime($d)); } ), array( 'db' => 'date_reforme', 'dt' => 10, 'formatter' => function( $d, $row ) { return date( 'jS M y', strtotime($d)); } ), /*array( 'db' => 'date_debut', 'dt' => 9 ), array( 'db' => 'date_reforme', 'dt' => 10 ),*/ array( 'db' => 'reforme', 'dt' => 11 ), array( 'db' => 'commentaire', 'dt' => 12 ) ); // SQL server connection information $sql_details = array( 'user' => 'monuser', 'pass' => 'monpass', 'db' => 'madb', 'host' => 'localhost' ); require( 'ssp.class.php' ); echo json_encode( SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns ) );
Je vous remercie d'avance pour l'aide que vous allez m'apporter.
Partager