Loading Data from txt not working
Loading Data from txt not working
![[Deleted User]](https://secure.gravatar.com/avatar/896f3dbf19e4d835f8926273eae08919/?default=https%3A%2F%2Fvanillicon.com%2F896f3dbf19e4d835f8926273eae08919_200.png&rating=g&size=120)
I have a txt named entries.txt looking like this:
[{
"id": "1",
"name": "Tiger Nixon",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
},
{
"id": "2",
"name": "Garrett Winters",
"position": "Accountant",
"salary": "$170,750",
"start_date": "2011/07/25",
"office": "Tokyo",
"extn": "8422"
}
]
My code is looking like this:
var table = $('#example').DataTable( {
"ajax": "./entries.txt",
"columns": [
{
"className": 'details-control',
"orderable": false,
dataSrc: ''
"defaultContent": ''
},
{ "id" },
{ "name" },
{ "position" },
{ "salary" },
{ "start_date" },
{ "office" },
{ "extn"}
]
My DataTable is saying "No data available in table" so I think I am doing something wrong in my columns. What am I missing?
This question has an accepted answers - jump to answer
Answers
You need to declare
columns.data
correctly. Instead of:have
for all those columns.
Colin