I'm currently pulling my hair out trying to get jQuery Datatables to work with a very simple json array. To my mind the output json matches the simple ajax example on the datatables site:
"{\"data\":[[\"Row1\",\"0\",\"1\",\"1\",\"2\",\"6\",\"0\",\"1\"],[\"Row2\",\"16\",\"11\",\"13\",\"13\",\"16\",\"2\",\"5\"],[\"Row3\",\"0\",\"1\",\"1\",\"0\",\"1\",\"0\",\"0\"],[\"Row4\",\"14\",\"8\",\"19\",\"16\",\"24\",\"3\",\"0\"],[\"Row5\",\"4\",\"0\",\"2\",\"1\",\"2\",\"2\",\"1\"]]}"
The only difference really is the fact that the output from my api is being escaped which I can't really help as it's being generated by JSON.NET. When debugging datatables in chrome I get a 'Uncaught TypeError: Cannot read property 'length' of undefined' exception.
Here is my HTML/JavaScript:
<script type="text/javascript">
$(document).ready(function() {
$('#incVolumes').dataTable( {
"ajax":"http://localhost/API/Reporting/Volumes"
} );
} );
</script>
<table id="incVolumes" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Worksource</th>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
<th>Col4</th>
<th>Col5</th>
<th>Col6</th>
<th>Col7</th>
</tr>
</thead>
</table>
I usually have to use Json.Parse to pass something like this to a jQuery plugin, but as I understand it datatables takes care of that anyway?
So my question is can anyone see where I'm going wrong?
data : data.data-> jsfiddle.net/x8678osL