sAjaxSource does not show any data
sAjaxSource does not show any data
Hi,
I'm new to data tables and currently trying to evaluate (PoC) it for large data sets.
I notice that sAjaxSource works OK when I have my JSON data sourced from a local file however, it does not display / render anything if configured to pull directly from a restful web service.
This works:
"bProcessing": true,
"sAjaxSource": "my-copied-json-data.txt",
"sAjaxDataProp": "",
This doesn't work:
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://localhost:9001/ismb/api/getMessage",
"sAjaxDataProp": "",
I can see the webservice is getting hit and returning data (from logs), although I don't see this being displayed inside the HTTP Response object on Firebug.I have also tried fnServerData param but with no gain!
The above webservice will return JSON that's validated OK on JSONLint, and looks like:
[
{
"busId": "1",
"domainId": x,
...
},
{
"busId": "2",
"domainId": y,
...
}
]
Appreciate help! Thanks
I'm new to data tables and currently trying to evaluate (PoC) it for large data sets.
I notice that sAjaxSource works OK when I have my JSON data sourced from a local file however, it does not display / render anything if configured to pull directly from a restful web service.
This works:
"bProcessing": true,
"sAjaxSource": "my-copied-json-data.txt",
"sAjaxDataProp": "",
This doesn't work:
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://localhost:9001/ismb/api/getMessage",
"sAjaxDataProp": "",
I can see the webservice is getting hit and returning data (from logs), although I don't see this being displayed inside the HTTP Response object on Firebug.I have also tried fnServerData param but with no gain!
The above webservice will return JSON that's validated OK on JSONLint, and looks like:
[
{
"busId": "1",
"domainId": x,
...
},
{
"busId": "2",
"domainId": y,
...
}
]
Appreciate help! Thanks
This discussion has been closed.
Replies
Allan
The test case submission service is unavailable, hence describing it here.
Let me know if need more info.
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Bus Test
@import "media/css/demo_page.css";
@import "media/css/demo_table.css";
$(document).ready(function() {
var oTable = $('#table_id').dataTable( {
"bProcessing": true,
//"bServerSide": true,
//"sAjaxSource": "http://localhost:9001/ismb/api/getMessage",
"sAjaxSource": "bus-poc-data.txt",
"sAjaxDataProp": "",
"aoColumns": [
{ "mData": "busId" },
{ "mData": "sourceSystem" },
{ "mData": "receiveTime" },
{ "mData": "validationStatus" },
{ "mData": "messageId" }
]
} );
} );
Bus Id
Message Id
Source System
Received
Validation Status
Bus Id
Message Id
Source System
Received
Validation Status
[/code]
Sample "bus-poc-data.txt" content:
[code]
[
{
"busId": "N02P02-f0e6f22b-3a0c-48b0-bd9a-df9b94c9714f",
"domainId": 1,
"sourceSystem": "TEST-NY-EDG",
"receiveTime": 1382453631320,
"validationStatus": "V",
"messageId": "123-default",
"messageType": null,
"routingStatus": "R",
"businessIds": null,
"recipients": null
},
{
"busId": "N02P02-efb99ce0-5ede-45c5-b5e6-64e1fc9cad25",
"domainId": 1,
"sourceSystem": "TEST-NY-EDG",
"receiveTime": 1382453631320,
"validationStatus": "V",
"messageId": "123-default",
"messageType": null,
"routingStatus": "R",
"businessIds": null,
"recipients": null
},
{
"busId": "N02P02-1e1bfcbd-a42f-484a-826d-35a0a9aeafcd",
"domainId": 1,
"sourceSystem": "TEST-NY-EDG",
"receiveTime": 1382453631320,
"validationStatus": "V",
"messageId": "123-default",
"messageType": null,
"routingStatus": "R",
"businessIds": null,
"recipients": null
}
]
[/code]
Allan
Is there a way to trace things i.e. enable debug? Firebug doest not flag any error, and using that I can see the response has no JSON in it.
Thanks
.. and to do with cross domain scripting issues.
One enhancement: the jsonp example here: http://www.datatables.net/beta/1.9/examples/server_side/jsonp.html
should ideally be configured to access cross-domain data i.e. from a public domain such as wikipedia, dbpedia or a host of other socio/tech services out there, instead! There's slight overhead, external dependency created, but on the net I think there's more value to users like me.
I now see a potential bug in code (lines 2037-2038 in jquery.dataTables.js, _fnAjaxUpdateDraw, with error on line 2038 complaining 'aData is undefined'. Two lines copied below - don't understand the first with declaration on - syntactically seems incorrect?
var aData = _fnGetObjectDataFn( oSettings.sAjaxDataProp )( json );
for ( var i=0, iLen=aData.length ; i
var aData = _fnGetObjectDataFn( oSettings.sAjaxDataProp )( json );
to:
(oSettings.sAjaxDataProp !== "") ?
_fnGetObjectDataFn( oSettings.sAjaxDataProp )(json) : json;
works!
Allan
Allan