(Newbie) Datatables with JSON call
(Newbie) Datatables with JSON call
Can anyone help me? I've been trying for two days now and failing to get my Liferay JSON service to work with the DataTable I've configured. Basically, I can see my page call the JSON service, it get's data back, but the table data isn't getting populated. If I take the same JSON response and put into the javascript directly, all is well with the world.
Here's my javascript call:
[code]
$(document).ready(function(){$("#seasonsTable").dataTable({
bFilter:false,bJQueryUI:true,
sAjaxSource:"/api/jsonws/GFSL_DB_Services-portlet.club/get-club-ids-and-names",
aoColumns:[{sTitle:"Id",mData:"id"},{sTitle:"Name",mData:"name"}],
bServerSide:true,
})
});
[/code]
The JSON returned by server is:
[code]
{\"iTotalDisplayRecords\":\"9\",\"iTotalRecords\":\"9\",\"aaData\":[{\"id\":\"1\",\"name\":\"147 Snooker Club\"},{\"id\":\"2\",\"name\":\"Stoke Snooker Club\"},{\"id\":\"3\",\"name\":\"Stubbington Village Snooker Club\"},{\"id\":\"4\",\"name\":\"Mayfair\"},{\"id\":\"5\",\"name\":\"Hillpark Working Mens Club\"},{\"id\":\"6\",\"name\":\"Lee On Solent Workings Mens Club \"},{\"id\":\"7\",\"name\":\"HMS Collingwood\"},{\"id\":\"8\",\"name\":\"Queens Club\"},{\"id\":\"9\",\"name\":\"Gosport Trades Club\"}],\"sEcho\":1}
[/code]
As stated, if I put the above JSON string into the javascript above as "aaData" all is well with the world.
You can also see the problem here:
--link removed--
Any help would be appreciated.
Kind regards
Carl
Here's my javascript call:
[code]
$(document).ready(function(){$("#seasonsTable").dataTable({
bFilter:false,bJQueryUI:true,
sAjaxSource:"/api/jsonws/GFSL_DB_Services-portlet.club/get-club-ids-and-names",
aoColumns:[{sTitle:"Id",mData:"id"},{sTitle:"Name",mData:"name"}],
bServerSide:true,
})
});
[/code]
The JSON returned by server is:
[code]
{\"iTotalDisplayRecords\":\"9\",\"iTotalRecords\":\"9\",\"aaData\":[{\"id\":\"1\",\"name\":\"147 Snooker Club\"},{\"id\":\"2\",\"name\":\"Stoke Snooker Club\"},{\"id\":\"3\",\"name\":\"Stubbington Village Snooker Club\"},{\"id\":\"4\",\"name\":\"Mayfair\"},{\"id\":\"5\",\"name\":\"Hillpark Working Mens Club\"},{\"id\":\"6\",\"name\":\"Lee On Solent Workings Mens Club \"},{\"id\":\"7\",\"name\":\"HMS Collingwood\"},{\"id\":\"8\",\"name\":\"Queens Club\"},{\"id\":\"9\",\"name\":\"Gosport Trades Club\"}],\"sEcho\":1}
[/code]
As stated, if I put the above JSON string into the javascript above as "aaData" all is well with the world.
You can also see the problem here:
--link removed--
Any help would be appreciated.
Kind regards
Carl
This discussion has been closed.
Replies