DataTables warning: table id=token-table - [object Object]
DataTables warning: table id=token-table - [object Object]
tarunsharma967
Posts: 1Questions: 1Answers: 0
I am getting following error for my datatable, i am not getting this error message.
DataTables warning: table id=token-table - [object Object]
var table1 = $('#token-table').DataTable( {
"ajax" : {
"url" : token,
"dataSrc": function ( data ) {
let arr = [];
for (key in data) {
arr.push({
name : key,
freq : data[key]['frequencycount'],
freqPercent : data[key]['percentvalue'],
});
}
return arr;
}
},
"columns": [
{ "data": "name" },
{ "data": "freq" },
{ "data": "freqPercent" },
],
deferRender : true,
scrollY : 500,
scroller : true,
} );
setInterval( function () { table1.ajax.reload(null,false) }, 10000 );
<table id="token-table">
<thead>
<tr>
<th class="col-md-6">Token Name</th>
<th class="col-md-3">Frequency count</th>
<th class="col-md-3">Frequency Percent</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
This is my code for dataTable.
Answers
Hi @tarunsharma967 ,
It looks like it should work. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
I am also have the same problem, this is my test case.
and this is my JS code:
Thank you.
I'm getting "This site can’t be reached : www.signaltekno.com took too long to respond." from Chrome.
Thanks, @tangerine. Sorry about that, my server hosting location is in Asia. So maybe it's taking too long when you are from another country. I didn't realize this before posting.
And this is my JSON file, in case. website can't be accessed.
This is my new updated test case. Sorry for the inconvenience.
Looks like you row data is in
data
notdata.developer
:You are getting this error:
You need to change everywhere you are using
data.developer
to just data, for example in this statement - which is generating the error:Kevin
Thanks, Kevin for your answer, but the warning alert is still shown. Even tho I changed the JSON file and add the developer field. The data is shown, but the alert dialog keep shown every time refreshes the page.
Have you debugged the result of your loop? What is the value of
data
before thereturn data
statement in theajax.dataSrc
function?Kevin
Hi to everyone.
I'm having the same problem. Can anyone help me? Everything looks ok.
$('#tb_statusGeral').DataTable({
searching: false,
scrollY: $('body').height() - 217,
lengthMenu: false,
pageLength: 20,
pagingType: "simple_numbers",
ordering: false,
language: {
processing: 'Processando...',
search: '',
lengthMenu: '',
info: 'PAGE - PAGES de MAX',
infoEmpty: 'Nenhum dado disponível',
infoFiltered: '',
infoPostFix: '',
loadingRecords: 'Carregando registros...',
zeroRecords: 'Nenhum dado disponível',
emptyTable: 'Realize uma busca de um status.',
searchPlaceholder: 'Pesquisar esta exibição',
paginate: {
first: 'Primeiro',
previous: '<i class="pag-arrow-left"></i>',
next: '<i class="pag-arrow-right"></i>',
last: 'Último'
}
}, ajax....
Help?
@vdsantos Its hard to say what the problem might be with what you posted. Not sure what the screenshot is showing. Use the browser's network inspector and show use a snippet of the XHR response. You removed the
ajax
option. Is it just the URL or do you have otherajax
options configured?Looks like you have an array of objects. Have you configured
columns.data
? See if the Data and Ajax docs help.Can you provide a link to your page or a test case replicating the issue so we can take a look?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
If not maybe the Debugger will give the developers the needed information to help. Post your generated ID.
Kevin
Hi, @denny_kurniawan, try to rename "error" property. I had the same problem and this helped me.
Similar to @denny_kurniawan
our api always returns a response object with an “error” object that is empty if there was no issue. We would see the alert and the Ajax error would just say
[object Object]
and then the rows would load without issue once the alert was closed. Worked around it by changing this particular api call to just return the data for now, but may try the ‘errMode’ config as mentioned at the end of the tech note for the Ajax error page. Just an FYI that may save someone timeDataTables expects the
error
property in the JSON return from the server to be a string. If you return an object, then yes, it would say[object Object]
since that is the.toString()
value of an object.Allan