Rendering json data in Spring using dataTable
Rendering json data in Spring using dataTable
Sean_india
Posts: 4Questions: 0Answers: 0
I am unable to render live data from server. Incase I am hardcoding my values into aaData para of DataTable, I am able to get proper result.
Kindly give advice on this. I am totally a newbie to this, so any help would be really appreciated.
Here is the code,
$(document).ready(function() {
$('#userinfo').dataTable({
// "bServerSide": true,
"bProcessing" : true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"dataType" : "json",
"sAjaxSource": "/jsonAjaxCall",
// "aaData" : [
//{"id":18,"firstName":"Sean","lastName":"Mike","email":"sean.m@y.com"}
//],
"aoColumns" : [
{
"mData" : "id"
},
{
"mData" : "firstName"
},{
"mData" : "lastName"
},{
"mData" : "email"
}
]
});
} );
The format of the data I am getting from server:
{"aaData" : [{"id":18,"firstName":"MyFirst","lastName":"Ylast","email":"xyz@y.com"},
{"id":19,"firstName":"Rock","lastName":"Jagger","email":"rocksJag@g.com"}
]}
Regards!
Kindly give advice on this. I am totally a newbie to this, so any help would be really appreciated.
Here is the code,
$(document).ready(function() {
$('#userinfo').dataTable({
// "bServerSide": true,
"bProcessing" : true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"dataType" : "json",
"sAjaxSource": "/jsonAjaxCall",
// "aaData" : [
//{"id":18,"firstName":"Sean","lastName":"Mike","email":"sean.m@y.com"}
//],
"aoColumns" : [
{
"mData" : "id"
},
{
"mData" : "firstName"
},{
"mData" : "lastName"
},{
"mData" : "email"
}
]
});
} );
The format of the data I am getting from server:
{"aaData" : [{"id":18,"firstName":"MyFirst","lastName":"Ylast","email":"xyz@y.com"},
{"id":19,"firstName":"Rock","lastName":"Jagger","email":"rocksJag@g.com"}
]}
Regards!
This discussion has been closed.
Replies
Allan
"DataTables warning (table id = 'userinfo'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error."
Thanks for your inputs !