jquery.dataTables.min.js:48 Uncaught TypeError: Cannot read property 'length' of undefi
jquery.dataTables.min.js:48 Uncaught TypeError: Cannot read property 'length' of undefi
HI, I'm getting this error, "jquery.dataTables.min.js:48 Uncaught TypeError: Cannot read property 'length' of undefined".
I believe it is able to read the json data. If I remove the json data file from the server I get a 404 error. So it at least finds the file.find
Here's the log from Chrome:
jquery.dataTables.min.js:48 Uncaught TypeError: Cannot read property 'length' of undefined
(anonymous function) @ jquery.dataTables.min.js:48
i @ jquery.dataTables.min.js:35
n.success @ jquery.dataTables.min.js:35
i @ jquery.min.js:2
j.fireWith @ jquery.min.js:2
y @ jquery.min.js:4
c @ jquery.min.js:4
Here's my json data
{"tradelist":[
{"station":"KELO", "producer":"PAMS", "package":"14", "mediano":"R-34-02"},
{"station":"KELO", "producer":"PAMS", "package":"Windy (WLS'76)", "mediano":"R149-006"},
{"station":"KELO", "producer":"PAMS", "package":"Windy", "mediano":"R149C-006"},
{"station":"KELO", "producer":"PAMS", "package":"14", "mediano":"R398-002"},
{"station":"KELO", "producer":"PAMS", "package":"10", "mediano":"R413-004"}
]}
Here's the html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
</head>
<body>
Station | Producer | Package | Media No |
---|
</body>
</html>
Thanks,
Steve
This question has an accepted answers - jump to answer
Answers
Here's a link to test:
http://560.com/guestbook.htm
By default DataTables will look for a property called
data
in the returned Ajax object (manual). You can change that using theajax.dataSrc
option - in this case you would want to set it to betradelist
.Since you are using objects for the data, you would also need to use
columns.data
to tell DataTables which property belongs to each column - manual.Allan
That fixed it. I get it now. Thanks for your help.