Sylvie Yunjae Sylvie Yunjae - 1 year ago 213
PHP Question

DataTables 1.10 parse aadata from json failed on HTML5

I'm currently working with HTML5, so I need to use DataTabels 1.10

The problem is the ajaxsouce failed to parse the json from the php file I have.
Actually it worked fine, and still works fine with my project on DataTables 1.9.4 and HTML4, but somehow I failed using it with DataTables 1.10 and HTML5

this is how I call my ajax :

$(document).ready(function() {
$('#example').dataTable( {
"ajax": "viewobat1.php"
} );

} );

I've changed to
"sAjaxSource": "viewobat1.php"
too, but wont work either

this is what I do in
to get json

$sql="SELECT * FROM obat";



I dont see any problem to my json, PHP is returning a valid JSON array

but the data won't show on table,

am I missing something ?


I've changed the way to get the required data with the server-side tutorial from ---> SERVER SIDE

my code come like this,

$table = 'obat';

$primaryKey = 'idobat';
$columns = array(
array( 'db' => 'idobat', 'dt' => 0 ),
array( 'db' => 'tanggalmasuk', 'dt' => 1 ),
array( 'db' => 'namaobat', 'dt' => 2 ),
array( 'db' => 'jenis', 'dt' => 3 ),
array( 'db' => 'macam', 'dt' => 4 ),
array( 'db' => 'keterangan', 'dt' => 5 ),
array( 'db' => 'stok', 'dt' => 6 ),

$sql_details = array(
'user' => 'root',
'pass' => '',
'db' => 'medical',
'host' => 'localhost'

require( 'js\DataTables-1.10.2\examples\server_side\scripts\ssp.class.php' );

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

and of course... PHP is returning valid data again


I called ajax the exact same way as the tutorial too...

and of course... the data still won't come out in my table...

so again, am I missing something ?? (O_o)

Answer Source

Yeey... I found my answer (it's weird answer)

just changed my script to -->

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

and it did all the trick... it's weird, isn't it...? i know..

I dont know why should I use CDN that required http instead and failed call it from my own server using PATH_TO_FOLDER method,

but it works anyway, reference from question --> cant get datatables net working with javascript

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download