JSON response to ajax call read as array of char
JSON response to ajax call read as array of char
I'm using a vb.net webmethod to return a JSON response using JsonConvert.SerializeObject from an ajax call. I'm getting a Requested unknown parameter '...' for row 0, column 0 error and then the datatable renders with the same number of rows as characters in the JSON response. The JSON is returning objects, not a simple array in the following format:
{d:[{},{}]}
My ajax does specify a "dataSrc" of "d".
How can I get it to read it as objects and not an array of characters?
This question has an accepted answers - jump to answer
Answers
Are you using the
columns.data
option to define your columns?If not please read the Data Source Types section of the Data manual to see how to use
columns.data
.If this doesn't help then please post your Datatables JS code and an example of your JSON response from the browser's network tools. Or use the debugger to collect this information. Post the debugger link here.
Kevin
Thanks. Here's a little more information. I think I am using the columns.data correctly, and I have made sure that my table columns match the number of columns in the js. I'm a bit stumped. I think the issue is with the formatting of the JSON, but I'm not sure how to output it differently.
My html:
My js:
The JSON (output from vb.net with JsonConvert.SerializeObject method. Microsoft .net adds the "d"):
Ok, I fixed it. The JSON was not getting processed correctly, so I had to wrap the dataSrc in a function like so: