I am currently utilizing a MongoDB database to store some important data. I am now looking to showcase this data on an HTML Datatable.
The data that I am attempting to utilize is organized in arrays, and here is its structure:
data: [[1848, 84857], [4944, 4949], [34, 65], [3566, 78], .... ]
$(document).ready(function() {
var table = $('#mytable').DataTable({
"serverSide": true,
"ajax": "/endpoint/?format=datatables",
"columns": [
{"data": 'data'},
]
});
setInterval( function () {
table.ajax.reload();
}, 10000 );
});
However, the issue with my current code is that it displays the datatable in the following format:
DATA:
[[1848, 84857], [4944, 4949], [34, 65], [3566, 78], .... ]
Whereas, I wish for it to appear as follows:
DATA:
1848, 84857
4944, 949
36, 65 and so forth
How can I go about resolving this problem? I was contemplating using a for loop, but I am unsure how to do that since I am directly calling the data within the table
variable.
The JSON response typically looks something like this:
{"data":"[[11756.53, 2.419583] .....