(SOLVED) JSON: Loading Data
(SOLVED) JSON: Loading Data
Konstantin
Posts: 9Questions: 0Answers: 0
Hello,
i'm new in DataTables und trying to configure my first application. I'm want data, that placed on the server, in JSON format be displayed in a dataTable. My JSON file has following format (http://jsonlint.com validated):
[quote]
{
"configuration":
{
"domain": "HPSM",
"name": "highPriorityUserIncidents",
"language": "en",
"version": "v01",
"creationgmttimestamp": "1320249079000",
"lastupdategmttimestamp": "1320249079000"
},
"data":
[
{
"uinumber": "INC9765",
"status": "open",
"title": "Printer doesnt print",
"assignmentgroup": "Service Desk",
"service": "IT Service"
},
{
"uinumber": "INC543",
"status": "closed",
"title": "Email",
"assignmentgroup": "Service Desk",
"service": "Email Service"
}
]
}[/quote]
Array of objects [code] "data":[{}][/code] should be displayed, like here described: http://datatables.net/release-datatables/examples/ajax/objects.html. But it doesnt work.
Here is the configuration:
[code]
$(document).ready(function() {
$('#highPriorityUserIncidents').dataTable( {
"bProcessing": true,
"sAjaxSource": "http://localhost:8080/myProxyService0.1/cache/highPriorityUserIncidents.json",
"aoColumns": [
{ "mDataProp": "uinumber" },
{ "mDataProp": "status" },
{ "mDataProp": "title" },
{ "mDataProp": "assignmentgroup" },
{ "mDataProp": "service" }
]
} );
} );
[/code]
And here is my table:
[code]
uinumber
status
title
assignmentgroup
service
Loading data from
server
uinumber
status
title
assignmentgroup
service
[/code]
Noting spacial. But i have [quote]"Processing..."[/quote] message before the table and [quote]"Loading..."[/quote] in the table. No JavaScript errors. I dont understand, what's wrong. Please help me :)))
i'm new in DataTables und trying to configure my first application. I'm want data, that placed on the server, in JSON format be displayed in a dataTable. My JSON file has following format (http://jsonlint.com validated):
[quote]
{
"configuration":
{
"domain": "HPSM",
"name": "highPriorityUserIncidents",
"language": "en",
"version": "v01",
"creationgmttimestamp": "1320249079000",
"lastupdategmttimestamp": "1320249079000"
},
"data":
[
{
"uinumber": "INC9765",
"status": "open",
"title": "Printer doesnt print",
"assignmentgroup": "Service Desk",
"service": "IT Service"
},
{
"uinumber": "INC543",
"status": "closed",
"title": "Email",
"assignmentgroup": "Service Desk",
"service": "Email Service"
}
]
}[/quote]
Array of objects [code] "data":[{}][/code] should be displayed, like here described: http://datatables.net/release-datatables/examples/ajax/objects.html. But it doesnt work.
Here is the configuration:
[code]
$(document).ready(function() {
$('#highPriorityUserIncidents').dataTable( {
"bProcessing": true,
"sAjaxSource": "http://localhost:8080/myProxyService0.1/cache/highPriorityUserIncidents.json",
"aoColumns": [
{ "mDataProp": "uinumber" },
{ "mDataProp": "status" },
{ "mDataProp": "title" },
{ "mDataProp": "assignmentgroup" },
{ "mDataProp": "service" }
]
} );
} );
[/code]
And here is my table:
[code]
uinumber
status
title
assignmentgroup
service
Loading data from
server
uinumber
status
title
assignmentgroup
service
[/code]
Noting spacial. But i have [quote]"Processing..."[/quote] message before the table and [quote]"Loading..."[/quote] in the table. No JavaScript errors. I dont understand, what's wrong. Please help me :)))
This discussion has been closed.
Replies
you can either change the name of the variable in your JSON or you can override the default name with sAjaxDataProp to read your "data" variable
[code]$(document).ready(function() {
$('#highPriorityUserIncidents').dataTable( {
"bProcessing": true,
"sAjaxDataProp": "data"
"sAjaxSource": "http://localhost:8080/myProxyService0.1/cache/highPriorityUserIncidents.json",
"aoColumns": [
{ "mDataProp": "uinumber" },
{ "mDataProp": "status" },
{ "mDataProp": "title" },
{ "mDataProp": "assignmentgroup" },
{ "mDataProp": "service" }
]
} );
} );[/code]
http://www.datatables.net/ref#sAjaxDataProp
[code]
$(document).ready(function() {
$('#highPriorityUserIncidents').dataTable( {
"bServerSide": false,
"aaData":
[
{
"uinumber": "INC9765",
"status": "open",
"title": "Printer doesnt print",
"assignmentgroup": "Service Desk",
"service": "IT Service"
},
{
"uinumber": "INC543",
"status": "closed",
"title": "Email",
"assignmentgroup": "Service Desk",
"service": "Email Service"
}
],
"aoColumns": [
{ "mDataProp": "uinumber" },
{ "mDataProp": "status" },
{ "mDataProp": "title" },
{ "mDataProp": "assignmentgroup" },
{ "mDataProp": "service" }
]
} );
} );
[/code]
it's everything okay. The data is being displayed
f.e. with
[code]
$(document).ready(function() {
$('#highPriorityUserIncidents').dataTable( {
"bProcessing": true,
"sAjaxDataProp": "data",
"sAjaxSource": "http://localhost:8080/ProxyService0.1/cache/highPriorityUserIncidents.json",
"aoColumns": [
{ "mDataProp": "uinumber" },
{ "mDataProp": "status" },
{ "mDataProp": "title" },
{ "mDataProp": "assignmentgroup" },
{ "mDataProp": "service" }
]
} );
} );
[/code]
and
[code]{
"configuration":
{
"domain": "HPSM",
"name": "highPriorityUserIncidents",
"language": "en",
"version": "v01",
"creationgmttimestamp": "1320249079000",
"lastupdategmttimestamp": "1320249079000"
},
"data":
[
{
"uinumber": "INC9765",
"status": "open",
"title": "Printer doesnt print",
"assignmentgroup": "Service Desk",
"service": "IT Service"
},
{
"uinumber": "INC543",
"status": "closed",
"title": "Email",
"assignmentgroup": "Service Desk",
"service": "Email Service"
}
]
}[/code]
i have no luck :(
[quote]Host localhost:8080
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept application/json, text/javascript, */*; q=0.01
Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Origin null[/quote]
Firebug Response Header:
[code]Server Apache-Coyote/1.1
Accept-Ranges bytes
Etag W/"589-1320417459000"
Last-Modified Fri, 04 Nov 2011 14:37:39 GMT
Content-Length 589
Date Fri, 04 Nov 2011 14:42:22 GMT[/code]
Response is empty. I dont know whether its okay. Any suggestions?