I'm trying to retrieve data from the server using DataTables.I can view the json response in the network section of my browser as well.But in the console it gives me TypeError: data is undefined. Nothing shows inside the table except column names and Processing.. label.
Here is my Json response:
{"userList":[{"age":23,"userId":123,"user_name":"Mike"},{"age":22,"userId":345,"user_name":"John"},{"age":23,"userId":123,"user_name":"Peter"}]}
Java Script:
$(document).ready(function () {
$('#mytable').dataTable({
"processing": true,
"serverSide": true,
"ajax": "jsond",
"columns": [
{"userList": "userId"},
{"userList": "user_name"},
{"userList": "age"}
]
});
});
Html:
<table id="mytable">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Id</th>
<th>Name</th>
<th>Age</th>
</tr>
</tfoot>
</table>
Can somebody suggest me a way to get rid of this error please ....