Loading Data not working
Loading Data not working
yondaimeninja
Posts: 2Questions: 1Answers: 1
I was referring to this question, but the solution does not work for me.
https://datatables.net/forums/discussion/32107/how-to-load-an-array-of-json-objects-to-datatables
My table simply says "Showing 1 to NaN of ## entries" (## being the total number of rows).
<script>
//results comes from an ajax function but looks like:
// [{ "Col 1": "Joseph Smith", "Col 0": 82, "Col 2": "Joseph Smith", "Col 3": "USA Project", "Col 4": "Loren Impsum dhdhd", "Col 5": "9901" }]
function (results) {
var table = $('#table-query-search');
table.DataTable({
destroy: true,
"searching": false,
"data": results,
"columns": [
{ "data": "Col 0" },
{ "data": "Col 1" },
{ "data": "Col 2" },
{ "data": "Col 3" },
{ "data": "Col 4" },
{ "data": "Col 5" }
]
});
}
</script>
<table id="table-query-search" class="table display">
<thead>
<tr>
<th class="no-sort"></th>
<th>Col 1</th>
<th>Col 2</th>
<th>Col 3</th>
<th>Col 4</th>
<th>Col 5</th>
</tr>
</thead>
</table>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Nevermind, I figured out the problem. Sorry for the post.