Loading Datatables from JSON Problem
Loading Datatables from JSON Problem

Hello,
I'm trying to take the following formatted JSON:
{
"status": "success",``
"data": {
"query": {
"numrows": 100,
"queryname=": "X_SR_OPEN_CLASSES",
"rows": [
{
"attr:rownumber": 1,
"STRM": "2203",
"CAMPUS": "CITY",
"SUBJECT": "BCAS",
"CATALOG_NBR": " 85",
"CRSE_DESCR": "Carpenter Apprentice I",
"CLASS_NBR": 27798,
"SEATS": "25",
"ROOM": "City-CLSRM",
"LOCATION": "Off Campus",
"START_DT": "2020-01-21",
"END_DT": "2020-06-01",
"EXPR29_29": "17:00",
"EXPR30_30": "18:25",
"EXPR31_31": "TTh",
"NAME": "SAMPLE, NAME",
"EMAIL_ADDR": "CSDEV92@erpdev.loc",
"EXPR19_19": ""
},
But when I load the tables I get a blank table, no error dialog pops up. Here's the javascript I'm using:
<script>
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"ajax": {
"url": "open_classes.json",
"dataSrc": "rows",
},
"columns": [
{ "data": "STRM" },
{ "data": "SUBJECT" },
{ "data": "CATALOG_NBR" },
{ "data": "CRSE_DESCR" },
{ "data": "CLASS_NBR" }
]
} );
} );
</script>
Any assistance would be greatly appreciated.
Thank you.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Have you tried changing your dataSrc property to:
It looks like it is nested even more than that (although hard to see without indentation):
should do it.
Allan
Looks like you JSON is structured like this:
To update @ntstravel 's answer looks like
ajax.dataSrc
needs to be"dataSrc": "data.query.rows"
.Kevin
Ah, that worked! Thank you for your help, was getting tunnel vision looking at it for so long.