Requested unknown parameter for 'id' for row 0
Requested unknown parameter for 'id' for row 0

Hi all,
Please hhhhhhhhhelp !!!!!!!!
I set up a datatable like this
var table = $('#jobs-table').dataTable({
ajax: {
type: "POST",
url: "/JeopardyService.svc/GetJobsGrid",
processData: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
dataSrc: function (json) {
//debugger;
return json.d;
}
},
columns: [
{
data: 'JobId'
},
{
data: 'LastEditor'
},
{
data: 'NumberOfEdits'
}
]
});
The result of json is : d:"[{"JobId":"1","LastEditor":"LastEditor","NumberOfEdits":"1"}]"
so I set dataSrc return json.d
But I still get the error "Requested unknown parameter for 'JobId' for row 0"
Do you know why?
html
<table id="jobs-table" class="table table-hover table-condensed" style="width: 100%">
<thead>
<tr>
<th>ID</th>
<th>LastEditor</th>
<th>NumberOfEdits</th>
</tr>
</thead>
</table>
On server:
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json
)]
public string GetJobsGrid()
{
List<Job> jobs = new List<Job>();
Job job = new Job();
job.JobId = "1";
job.LastEditor = "LastEditor";
job.NumberOfEdits = "1";
jobs.Add(job);
return JsonConvert.SerializeObject(jobs);
}
[Serializable]
public class Job
{
public string JobId { get; set; }
public string LastEditor { get; set; }
public string NumberOfEdits { get; set; }
}
Thank you
Tang
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
It looks like the data is wrong:
d
is a string in that data, and not an element. If you follow the tech note in that error, here for your reference, that should help. You probably want aJSON.parse()
on the returned data,Colin
thank you very much Colin