Loading forever
Loading forever
jerlabor
Posts: 3Questions: 3Answers: 0
Datatables wont show any data, only the "loading..."
$('#storeTarget').DataTable({
ajax: '/store-visit/targets',
columns: [
{data: 'month'},
{data: 'year'},
{data: 'num_of_stores'},
{data: 'created_at'},
{data: 'month'},
]
});
//Json Response
{
"draw": 0,
"recordsTotal": 2,
"recordsFiltered": 2,
"data": [
{
"month": "12",
"year": "2019",
"num_of_stores": "3",
"created_at": "2019-05-02 14:32:39"
},
{
"month": "6",
"year": "2020",
"num_of_stores": "3",
"created_at": "2019-05-02 14:41:01"
}
],
"input": []
}
\\HTML code
<table class="table responsive" id="storeTarget">
<thead class="table__thead">
<tr>
<th class="table__th">Month</th>
<th class="table__th">Year</th>
<th class="table__th"># of Stores</th>
<th class="table__th">Created At</th>
<th class="table__th">Action</th>
</tr>
</thead>
<tbody class="table__tbody"></tbody>
</table>
This discussion has been closed.
Answers
Hi @jerlabor ,
It works here with the data in a variable, so that side is fine. Are you able to modify that to demonstrate the problem or link to your page?
Cheers,
Colin
Look at your browser's console for errors. Verify the JSON response in the Developer Tools > Network tab.
Kevin
I was able to solve this problem by adding this to my servlet that is providing the data for populating my table: