loading table from AJAX
loading table from AJAX
robDaniel
Posts: 3Questions: 2Answers: 0
My HTML looks like this :
<table id='userTable' class='table table-striped table-bordered' >
<thead>
<tr><th>Column One</th><th>Column Two</th><th>Column Three</th></tr>
</thead>
<tbody></tbody>
</table>
I initialise dataTables like this :
$('#userTable').DataTable({
"ajax": {
"url": "data.json"
},
});
data.json looks like this :
{
"data": ["columnOne","second column","3rd col" ]
}
But my table looks like this on the screen :
Column One Column Two Column Three
3 r d
c o l
s e c
ie - 1 Character from each string per column
What am I doing wrong ?
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
My data.json was wrong.
Needs to be :
Note the extra pair of [ ] brackets
That is correct - thanks for posting back. The
data
parameter should be an array of arrays or an array of objects (i.e. one entry for each row in the table).Allan