Data from database not loading on Datatable
Data from database not loading on Datatable
My datatable is not loading i am only getting "Loading..." on my browser. Also when inspect i get the error below.
Uncaught TypeError: Cannot read property 'length' of undefined
at datatables.min.js:48
at i (datatables.min.js:35)
at Object.success (datatables.min.js:35)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
Here is data from database:
Array
(
[0] => 490
[atm_id] => 490
[1] => 123220
[terminal_id] => 123220
[2] => CDMN_67_1
[terminal_name] => CDMN_67_1
[3] => 201
[branch_code] => 2012
[4] => Onsite
[onsite_offsite] => Onsite
[5] => NCRC
[vendor_FK] => NCRC
[6] => 10.0.8.1
[local_ip] => 10.0.8.2
[7] => JUSTINA
[custodian_name] => JUSTINA
[8] => 10.0.85.1
[default_gateway] => 10.0.8.1
[9] => LAGOS ISLAND 1
[region] => LAGOS ISLAND 1
)
Here is html:
table class="table" id="manageAtmFleetTable">
<thead>
<tr>
<th>S/N</th>
<th>Terminal ID</th>
<th>Terminal Name</th>
<th>Branch code</th>
<th>Site Location</th>
<th>vendor</th>
<th>Local IP</th>
<th>Custodian Name</th>
<th>Default Gateway</th>
<th>Region</th>
</tr>
</thead>
</table>
</div>
</div>
Here is javascript:
var manageAtmFleetTable;
$(document).ready(function() {
// top bar active
$("#navAtmFleet").addClass('active');
//manage brand Table
manageAtmFleetTable = $("#manageAtmFleetTable").DataTable({
'ajax' : 'php_action/fetchTerminal.php',
'order' : []
});
here is fetchTerminal.php:
<?php
require_once 'core.php';
$sql = "SELECT atm_id, terminal_id, terminal_name, branch_code,
onsite_offsite, vendor_FK, local_ip, custodian_name, default_gateway,
region FROM atm_database ORDER BY atm_id DESC ";
$result = $connect->query($sql);
$output = array('data' => array());
if($result->num_rows > 0) {
while($row = $result->fetch_array()) {
// echo "
"; // print_r($row); // echo "
";
$atmId = $row[0];
$output['data'][] = array(
$atmId,
$row[1],
$row[2],
$row[3],
$row[4],
$row[5],
$row[6],
$row[7],
$row[8],
$row[9]
);
} // while
} // /if
$connect->close();
echo json_encode($output);
Please i need help
Replies
Please don't duplicate posts. You already have a thread started here:
https://datatables.net/forums/discussion/44621/table-data-not-loading-data-it-is-only-showing-loading
Kevin
Apologises