json Data not displayed on the datatable
json Data not displayed on the datatable
Hi,
I have customized my data in a json format accepted by Datatables. But i dont see any data on my tables.
Here is my code. Please let me know, if i am missing any steps here.
[code]
var oTable2 = $('#example2').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bRetrieve": true,
"bDestroy": true,
"aoColumns": [{ "sName": "systemID"},
{ "sName": "clientID"},
{ "sName": "clientDesc"},
{ "sName": "clientName"},
{ "sName": "intentID"},
{ "sName": "vendorOutputLocationId"},
{ "sName": "outputLocDesc"},
{ "sName": "vendorOutputLocationDir"},
{ "sName": "systemName"},
{ "sName": "intentName"},
{ "sName": "clientActive"},
{ "sName": "intentActive"}],
"sAjaxSource": 'http:/getPostalFulfillment.json',
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "i", "value":$("#IntentIds option:selected").val()},
{ "name": "sort", "value": "systemName"},
{ "name": "filter", "value": "null"},
{ "name": "dir", "value": "ASC"}
)
var xhr = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"async":false,
"success": function(response){
var json = response.result.model
alert("json: "+ json);
fnCallback(json);
}
});
}
} );
[/code]"
Thanks
I have customized my data in a json format accepted by Datatables. But i dont see any data on my tables.
Here is my code. Please let me know, if i am missing any steps here.
[code]
var oTable2 = $('#example2').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bRetrieve": true,
"bDestroy": true,
"aoColumns": [{ "sName": "systemID"},
{ "sName": "clientID"},
{ "sName": "clientDesc"},
{ "sName": "clientName"},
{ "sName": "intentID"},
{ "sName": "vendorOutputLocationId"},
{ "sName": "outputLocDesc"},
{ "sName": "vendorOutputLocationDir"},
{ "sName": "systemName"},
{ "sName": "intentName"},
{ "sName": "clientActive"},
{ "sName": "intentActive"}],
"sAjaxSource": 'http:/getPostalFulfillment.json',
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "i", "value":$("#IntentIds option:selected").val()},
{ "name": "sort", "value": "systemName"},
{ "name": "filter", "value": "null"},
{ "name": "dir", "value": "ASC"}
)
var xhr = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"async":false,
"success": function(response){
var json = response.result.model
alert("json: "+ json);
fnCallback(json);
}
});
}
} );
[/code]"
Thanks
This discussion has been closed.
Replies
{
"aaData": [
[
"00000000-0000-0000-0000-000000000016",
"AF8D776E-3AD8-4CCE-A410-2C932C236A49",
"Blue Shield of California",
"78",
"4",
"Right Fax",
"c:/touchengine/fax",
"Apollo",
"BSCA",
"Provider Fax -Provider Alert",
"true",
"true"
],
[
"00000000-0000-0000-0000-000000000016",
"F6EE191F-E512-4BE2-8FE2-D68D323C93C4",
"State of Kansas",
"78",
"4",
"Right Fax",
"c:/touchengine/fax",
"Apollo",
"State of Kansas",
"Provider Fax -Provider Alert",
"true",
"true"
],
[
"00000000-0000-0000-0000-000000000016",
"AD498633-0B09-4F02-9524-B561A9C842C8",
"BCBS of Michigan",
"78",
"4",
"Right Fax",
"c:/touchengine/fax",
"Apollo",
"BCBS of Michigan",
"Provider Fax -Provider Alert",
"true",
"true"
],
[
"00000000-0000-0000-0000-000000000022",
"AF8D776E-3AD8-4CCE-A410-2C932C236A49",
"Blue Shield of California",
"78",
"null",
"null",
"null",
"Care Alerts",
"BSCA",
"Provider Fax -Provider Alert",
"true",
"true"
],
[
"00000000-0000-0000-0000-000000000017",
"AF8D776E-3AD8-4CCE-A410-2C932C236A49",
"Blue Shield of California",
"78",
"4",
"Right Fax",
"c:/touchengine/fax",
"PCMS",
"BSCA",
"Provider Fax -Provider Alert",
"true",
"true"
]
]
}
Anybody could please help me with this code.
I tried in firefox, it does not like the variable "respose" on success.
But still I can access that variable and get just the required json data from response.result.model .
How that can be ?
Allan
Thank you so much for the response.
I eliminated ( bServerSide": true ). Actually, Allan I also updated the succcess part of the Ajax call. Instead of using the "response" parameter, I replaced it with "json" parameter. Now i dont get that error "response unidentified" but i get another error: "json.aaData is undefined".
This is the respose and json details , i am getting in firefox:
------------------------
response:
{"result":{"class":"xxx","model":"{\"aaData\":[[\"00000000-0000-0000-0000-000000000004\",\"802F156E-1A08-4EFC-85CD-DF3DF3A54500\",\"Rockwell Collins\",\"83\",\"null\",\"null\",\"null\",\"CorConnect\",\"Rockwell Collins\",\"Apollo Health Coaching Email \",\"true\",\"true\"]]}","requestURL":"http://getPostalFulfillment.json","timestamp":1305224837305}}
-----------------------------
JSON:
result Object { class="xxx", model="{"aaData":[["00000000-0...ail 2","true","true"]]}", more...}
class "xxx"
model "{"aaData":[["00000000-0000-0000-0000-000000000004","802F156E-1A08-4EFC-85CD-DF3DF3A54500","Rockwell Collins","83","null","null","null","CorConnect","Rockwell Collins","Apollo Health Coaching Email 2","true","true"]]}"
requestURL
"http://getPostalFulfillment.json"
timestamp
1305224837305
----------------------------------
Here is my updated code:
[code]
var oTable2 = $('#example2').dataTable( {
"bProcessing": true,
"bRetrieve": true,
"bDestroy": true,
"aoColumns": [{ "sName": "systemID"},
{ "sName": "clientID"},
{ "sName": "clientDesc"},
{ "sName": "clientName"},
{ "sName": "intentID"},
{ "sName": "vendorOutputLocationId"},
{ "sName": "outputLocDesc"},
{ "sName": "vendorOutputLocationDir"},
{ "sName": "systemName"},
{ "sName": "intentName"},
{ "sName": "clientActive"},
{ "sName": "intentActive"}],
"sAjaxSource": 'http://getPostalFulfillment.json',
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "i", "value":$("#IntentIds option:selected").val()},
{ "name": "sort", "value": "systemName"},
{ "name": "filter", "value": "null"},
{ "name": "dir", "value": "ASC"}
)
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(json){
var json = json.result.model;
alert("json: "+ json);
//var test = json;
//alert("test: "+ test);
fnCallback(json);
}
});
}
} );
});
[/code]
json.result.model.aaData (or possibly json.model.aaData)
Allan
"json is undefined" for:
[code]
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(json){
var json = json.result.model.aaData;
alert("json: "+ json);
fnCallback(json);
}
});
[/code]
and "json.model is undefined" for:
[code]
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(json){
var json = json.model.aaData;
alert("json: "+ json);
fnCallback(json);
}
});
[/code]
json.model is undefined
Allan
Please let me know, if there is a way i could send you some screenshots or the entire code.
Thanks.
json: {"aaData":[["00000000-0000-0000-0000-000000000016","31E8AB83-AC7D-458C-9794-019AAD134946","State Farm","94","null","null","null","Apollo","State Farm","Member Announcement State Farm Retiree","true","true"],["00000000-0000-0000-0000-000000000005","31E8AB83-AC7D-458C-9794-019AAD134946","State Farm","94","null","null","null","TRAX DM","State Farm","Member Announcement State Farm Retiree","true","true"]]}
This looks like json is having a valid data.
Then why does it still complain:
"json.aaData is undefined"
[code]
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(json){
var json = json.result.model;
alert("json: "+ json);
fnCallback(json);
}
});
[/code]
Allan
I got it working using "eval", Thanks so much for your quick replies.
[code]
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(json){
var json = eval('('+ json.result.model + ')');
alert("json: "+ json);
fnCallback(json);
}
});
[/code]