Open marcrobertson opened 9 years ago
Sorry, should have expected that the html would be rendered. Here's the jTable code in the page
$(document).ready(function () {
$('#NewsEntryContainer').jtable({
title: 'Current News Items',
actions: {
listAction: '/sleepydog/helpers/news/get.php'
},
fields: {
id: {
key: true,
list: false
},
begin_date: {
title: 'Begin Date',
width: '20%',
type: 'date'
},
end_date: {
title: 'End Date',
width: '20%',
type: 'date'
},
news_text: {
title: 'News Text',
width: '60%'
}
}
});
});
$('#NewsEntryContainer').jtable('load');
$('#NewsEntryContainer').jtable('load');
take this statement just after jtable initialization. in the above code you are calling $('#NewsEntryContainer').jtable('load');
before document load event which means your jtable is also not initialized
I'm trying out jTable to set up a page to edit news items for a site I'm developing. The news table has 4 columns:
id, begin_date, end_date, news_text.
Here's the code for the page:
<!DOCTYPE html>
News Administration
here's the code for get.php: <?php //Get records from database // create db connection $servername = "localhost"; $username = "root"; $password = ""; $database = "sleepydog";
$conn = new mysqli($servername, $username, $password, $database);
// check the connection if ( !$conn) { die( "Connection to database failed:".mysqli_connect_error()); }
$result = $result = $conn->query("SELECT * FROM news_items;"); if ($result->num_rows > 0) { $rows = array(); // output data of each row while($row = $result->fetch_assoc()) { $rows[] = $row; } $jTableResult = array(); $jTableResult['Result'] = "OK"; $jTableResult['Records'] = $rows; print json_encode($jTableResult); }
?>
When I debug in Chrome, I don't see the get.php request being made, and the displayed table shows "no data available". I've been looking through this for a while, and I'm just not seeing the, presumably stupid, mistake I'm making.
Marc Robertson