Requested Unknown Parameter - http://datatables.net/tn/4
Requested Unknown Parameter - http://datatables.net/tn/4
Hello - very new to datatables and I can't seem to figure out this issue.
Javascript:
$(document).ready(function () { $.ajax({ url: 'http://localhost:61009/api/TableData', method: 'post', dataType: 'json', success: function (data) { $('#example').DataTable({ data: data, columns: [ { data: 'FirstName' } ] }); } }); });HTML Code:
<body>
<table id="example">
<thead>
<tr>
<th>FirstName</th>
</tr>
</thead>
<tfoot>
<tr>
<th>FirstName</th>
</tr>
</tfoot>
</table>
</body>
My Web Service Returns the following JSON:
"{\"data\":[{\"FirstName\":\"John\"},{\"FirstName\":\"Fred\"}]}"
Which parses as valid JSON. The funny thing is if I save the JSON string as a file and (removing the escape characters) specify that as my JSON via the AJAX property it works. Any help would be greatly appreciated.
Thanks!
This question has an accepted answers - jump to answer
Answers
Your web-service is returning a string, not a JSON object. You need to return:
Note the lack of outer quotes.
Allan
That was it! Thank you so much!