Firstly sorry for my bad explaination.Currently ,I have a table that probably will be inserted data until 3000 and I got suggestion by people to use datatables.But I'm really new in this and I already try another datatables examples but still not working.
I already create datatables for server-side that is Object data source but seem like it not working well as what I expected .Please help me to show the correct way how to create datatables by json Object data source .Below is my code :
<script type="text/javascript" charset="utf8" src="../cdc/datatables/media/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" charset="utf8" src="../cdc/datatables/media/js/jquery.dataTables.min.js"></script>
<script language="javascript">
$(document).ready(function() {
$('#cdcTracking-list').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "../cdc/load/jsonTrack.php",
"columns": [
{ "elements": "vesselCode" },
{ "elements": "voyage" },
{ "elements": "chasisNo" },
{ "elements": "plateNo" },
{ "elements": "bookingRef" },
{ "elements": "serviceTerm" }
]
} );
} );
</script>
<table id="cdcTracking-list" class="display">
<thead>
<tr>
<th>No. </th>
<th>Vessel </th>
<th>Voyage </th>
<th>Chasis No</th>
<th>Plate</th>
<th>Booking Ref</th>
</tr>
</thead>
</table>
$getSessionList = getVehicleTrkDetail();
if (count($getSessionList) > 0) {
$data = array();
for ($i = 0; $i < count($getSessionList); $i ++) {
$getSessionListRecord = $getSessionList[$i];
$data[$i] = array(
vesselCode => $getSessionListRecord['vesselCode'],
voyage => $getSessionListRecord['voyage'],
chasisNo => $getSessionListRecord['chasisNo'],
plateNo => $getSessionListRecord['plateNo'],
bookingRef => $getSessionListRecord['bookingRef']
);
}
$json = array(
status => "success",
elements => $data
);
} else {
$json = array(
status => "failure"
);
}
echo json_encode($json);
{"status":"success","elements":[
{"vesselCode":"CE",
"voyage":"V01",
"chasisNo":"PL82A53DR61302244 ",
"plateNo":null,
"bookingRef":"V007\/E\/-00006"},
{"vesselCode":"CE",
"voyage":"V01",
"chasisNo":"PL1C21LNR6B101100",
"plateNo":null,
"bookingRef":"V007\/E\/-00006"}
Please someone help me for my beginner experience.Thanks