json response is not rendering on jquery data table
json response is not rendering on jquery data table
i'm trying to show a json response from server side to a jquery data table. but it's unable to render on the data table . i can see the response in chrome when i inspect it .
my response is like :-
[
{
"id": 22,
"name": "FPS-T25831236-1450251690209",
"lastUpdated": 1450251690213,
"createdBy": "Janaki",
"onBoarded": 1450251668000,
"activeFlag": true,
"createdBySafeId": "UC192791",
"sourceApplication": "FPS",
"subSource": "T25831236",
"type": "orderid",
"tag": [
"Arunesh",
"mamatha"
],
"comment": null,
"privateNote": true,
"reference": [
"T25831111"
],
"expiryDate": 1606630852
},
{
"id": 23,
"name": "FPS-T25831236-1450251728342",
"lastUpdated": 1450251728347,
"createdBy": "Janaki",
"onBoarded": 1450251668000,
"activeFlag": true,
"createdBySafeId": "UC192791",
"sourceApplication": "FPS",
"subSource": "T25831236",
"type": "orderid",
"tag": [
"Arunesh",
"mamatha"
],
"comment": null,
"privateNote": true,
"reference": [
"T25831111"
],
"expiryDate": 1606630852
}
]
and my javascript code is :-
$(function() { $( "#customerDialog" ).dialog({ autoOpen: false, title: "Customers", hide: "explode", modal: true, width: 500 }); $('#custTable').dataTable({ bJQueryUI: true, "processing": true, "serverSide": true, "contentType": "application/json", "dataType": "jsonp", "bStateSave": false, "bAutoWidth": false, "sAjaxSource": "http://url", "sAjaxDataProp": '', "crossDomain":true, "aoColumns": [{ "mData":"createdBy" },{ "mData": "createdBySafeId" },{ "mData": "lastUpdated" },{ "mData": "tag", "render": function(d) { return d.join(", ") } }], "fnServerData" : function(sSource, aoData, fnCallback) { $.getJSON(sSource, aoData, function(json) { map = {}; map["aaData"] = json; fnCallback(map); }); } }); $( "#opener" ).click(function() { $( "#customerDialog" ).dialog( "open" ); $('#customerDialog').dialog("widget").position({ }); }); });and the html code :-
<body>
<!-- HTML -->
<div id="customerDialog">
| createdBy | createdBySafeId | Last modified | Tag |
|---|
</div>
<button id="opener">Open Dialog</button>
</body>
This question has an accepted answers - jump to answer
Answers
sorry ,, this is the formatted javascript code
but
Seems like you should just be returning
jsonif its an array.Also worth pointing out you are using a lot of legacy options such as fnServerData etc there.
Allan
thanks allan , i removed the fnServerData function and now it's working fine ..
i was doin it wrong i guess