I am attempting to set the source of my DataTable as an array, but I am getting this error:
Uncaught Error: DataTables warning: table id=my-table - Requested unknown parameter '0' for row 0, column 0
This is my syntax that I am wanting to use:
<script type="text/javascript">
var information = <?php echo json_encode($data) ?>;
alert(information.toString());
$(document).ready(function () {
$('#my-table').dataTable({
data: information,
columns: [
{ title: 'Employee' },
{ title: 'TotalSales' },
{ title: '30DaySales' },
{ title: '60DaySales' }
]
});
});
</script>
What alterations need to be made to the code so that the error is removed and the DataTable is displayed?
EDIT
And below is the output of console.log so you can see the format my array is in.
Console.log(JSON.stringify(information[0]))
[{"Employee":"Mitch McConell","Total Sales:"1,000.00","30DaySales:"750.00","60DaySales":"350.00"}]