I’m pretty stuck as to why I’m receiving this error from JQuery Datatables “DataTables warning: table id=myTable – Requested unknown parameter ‘0’ for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4″. I’ve tried to review the website info but it didn’t make much sense to me. My only guess is that it has something to do with the way the data may be formatted. If so, I’m unsure how to resolve the issue.
This chunk of code is getting the API so I can view it in the console and then again for the datatable data.
var apiKey = "0ca80ddc-63f6-476e-b548-e5fb0934fc4b";
$.ajax({
type: "GET",
url: "http://brew-roster-svc.us-e2.cloudhub.io/api/teams",
headers: { "api-key": apiKey },
success: function(result){
console.log(result)
console.log(JSON.stringify(result));
}
});
$(document).ready( function () {
$('#myTable').dataTable({
"ajax": {
"url": "http://brew-roster-svc.us-e2.cloudhub.io/api/teams",
"type": "get",
"dataSrc": "",
"beforeSend": function (request) {
request.setRequestHeader("api-key", apiKey);
},
"columns": [
{ "data": "logo" },
{ "data": "name" },
{ "data": "league" },
{ "data": "division" },
],
}
});
});
Here are the results from my debugging Ajax results in the console.
(30) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
This portion is a snippet of what I see when expanded:
0: {id: 133, nickname: 'Athletics', name: 'Oakland Athletics', location: 'Oakland', abbreviation: 'OAK', …}
1: {id: 134, nickname: 'Pirates', name: 'Pittsburgh Pirates', location: 'Pittsburgh', abbreviation: 'PIT', …}
[[Prototype]]: Array(0)