Unable to display external nested object data
Unable to display external nested object data
Hello, I'm trying to use the example you have on this page (https://datatables.net/examples/ajax/deep.html) but none of my json data is being returned. Instead, I'm stuck with "Loading..." or "Processing.." text. I'm not sure if it's because my json has multiple nested objects, but I was hoping you could help.
html
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Date</th>
<th>Away</th>
<th>GF</th>
<th>Home</th>
<th>GF</th>
<th>Time</th>
</tr>
</thead >
</table >
javascript
<script>
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"ajax": "https://lscluster.hockeytech.com/feed/?feed=modulekit&view=schedule&key=33dcb980ec36bdaf&fmt=json&client_code=ahl&lang=en&season_id=xxx&team_id=321&league_code=&fmt=json",
"columns": [
{ "data": "id" },
{ "data": "game_id" },
{ "data": "season_id" },
{ "data": "home_team" },
{ "data": "date_played" },
{ "data": "date" }
]
} );
} );
</script>
Thanks
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
you need to use the dataSrc option ( https://datatables.net/reference/option/ajax.dataSrc ) to tell DataTables where the data is. By default dataSrc = "data" but in your cause it looks like it might be
dataSrc ="SiteKit.Schedule"
You're amazing!! Thank you. I spent hours working on this... I tried using dataSrc previously but I just put = 'Schedule' not 'SiteKit.Schedule' -_-
Anyway, thank you!