I have a table that is populated via dataTables with information from a MySQL table. The information is prepared via PHP as proper JSON in the way dataTables expects the information.
The problem I'm having is the table no longer loads informations. Even reverting my changes so that the JSON data does not include links to the server description (via view.php) doesn't change anything.
The site can be found here: checkersthecat.com/status The PHP that outputs JSON information can be found here: checkersthecat.com/status/inc/json-servers.php
Here is the code for json-servers.php
<?php
$db = new PDO("mysql:host=localhost;dbname=mcstatus;charset=UTF8", "user", "pass");
$stmt = $db->prepare("SELECT ip, port, category, players, tries, description FROM clients");
$stmt->execute();
$servers = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
$data = array(
"aaData" => array()
);
foreach ($servers as $item) {
$arr = array();
// Address
if (strlen($item['description']) == 0) {
if ($item['port'] != 25565) {
array_push($arr, $item['ip'] . ":" . $item['port']);
} else {
array_push($arr, $item['ip']);
}
} else {
if ($item['port'] != 25565) {
array_push($arr, "<a href='inc/view.php?ip=" . $item['ip'] . "'>" . $item['ip'] . ":" . $item['port'] . "</a>");
} else {
array_push($arr, "<a href='inc/view.php?ip=" . $item['ip'] . "'>" . $item['ip'] . "</a>");
}
}
// Category
array_push($arr, $item['category']);
// Status
if ($item['tries'] == 0) {
array_push($arr, "Up");
} else {
array_push($arr, "Down (" . $item['tries'] . ")");
}
// Players
if ($item['players'] == -1) {
array_push($arr, "?");
} else {
array_push($arr, $item['players']);
}
array_push($data['aaData'], $arr);
}
header("Content-type: application/json");
echo json_encode($data);
?>
The snippet of javascript that actually initializes and sets up the dataTable is here:
// init load of table
serverTable = $("#servers").dataTable({
"bProcessing": true,
"bStateSave": true,
"sPaginationType": "two_button",
"sAjaxSource": "http://checkersthecat.com/status/inc/json-servers.php"
});
It literally worked, I changed one small item relating to the description length in the javascript relating to a jQuery modal dialog form, I refreshed the page, and suddenly dataTables no longer loads my JSON information.
I'm at a total loss as to why it will not work. Even reverting to my old code without the hyperlinks in the JSON data and previous description limits doesn't make a difference. It still gives me an endless "Processing" and "Loading". When I try to search it merely says "No data available" which is ludicrous as the JSON information is right there at the URL and is valid.
I've tried debugging the javascript and PHP with firebug and turning on error reporting respectively, but apparently there isn't anything wrong with it all as far as I know.
Any help is very appreciated as this has had me tearing my hair out. If there's any other details that you may need, please let me know.