Rendering json data in Spring using dataTable

Rendering json data in Spring using dataTable

Sean_indiaSean_india Posts: 4Questions: 0Answers: 0
edited November 2013 in General
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!

Replies

  • allanallan Posts: 62,613Questions: 1Answers: 10,294 Site admin
    It looks correct to me. Please link to a test case showing the issue so we can offer some help.

    Allan
  • Sean_indiaSean_india Posts: 4Questions: 0Answers: 0
    Well I have placed the above piece of code in js file. This file is being called during execution of my jsp page. And, while I compile and run my application, following is the message that comes in..

    "DataTables warning (table id = 'userinfo'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error."
  • Sean_indiaSean_india Posts: 4Questions: 0Answers: 0
    Good News! Issue got resolved.. Reason for error was an extra ']' at the end of the result was getting added down in the code which I was using.
    Thanks for your inputs !
This discussion has been closed.