Rendering JSON data
Rendering JSON data
Harish
Posts: 2Questions: 0Answers: 0
Hi,
I'm kind of lost on the datatable, the following is my code in the js file and I need to know how to get the rendering correctly up. Any help is really appreciated.
HTML Code
[code]
Users In The System
Username
First Name
Last Name
Acid
Last Login
[/code]
JS Code
[code]
$(document).ready(function() {
$.ajax({
url : "http://localhost/v1/user/active",
type : "GET",
data : "uid=" + readCookie("uid") + "&key=" + readCookie("key"),
success : function(data) {
alert(JSON.stringify(data));
$('#usertable').dataTable({
"sAjaxDataProp": JSON.stringify(data),
// "bProcessing": true,
"aoColumnDefs": [
{
"mDataProp": "acid",
"aTargets": [0]
},
{
"mDataProp": "firstname",
"aTargets": [1]
},
{
"mDataProp": "lastlogin",
"aTargets": [2]
},
{
"mDataProp": "lastname",
"aTargets": [3]
},
{
"mDataProp": "username",
"aTargets": [4]
}
],
// "sDom": 't<"dataTables_footers_dash"ip>',
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"bAutoWidth": false,
"bJQueryUI": true,
});
// $('#usertable').dataTable({
// "aaData": JSON.stringify(data),
// "aoColumnDefs": [{ "mDataProp": "acid" },
// { "mDataProp": "firstname"},
// { "mDataProp": "lastlogin"},
// { "mDataProp": "lastname"},
// { "mDataProp": "username"}
// ]
// });
},
error : function(data){
location.replace("500.html");
}
});
});
[/code]
JSON Returned by the REST Call is given below
[code]
{"tUsers":{"acid":"ccd6687e-32ab-11e1-af7e-992b0cb8782f","firstname":"Jonathan","lastlogin":"2012-01-17 18:42:46.0","lastname":"Keshrew","username":"harish@mailme.com"}}
[/code]
Most of the examples use either use a text file to load the data or run some PHP file on the server side. In our case all the transactions with the server happens using a token exchange to authorize it self. I'm not even sure whether i'm doing the right thing, any pointer to this kind of use case is really appreciated.
Thanks in advance.
I'm kind of lost on the datatable, the following is my code in the js file and I need to know how to get the rendering correctly up. Any help is really appreciated.
HTML Code
[code]
Users In The System
Username
First Name
Last Name
Acid
Last Login
[/code]
JS Code
[code]
$(document).ready(function() {
$.ajax({
url : "http://localhost/v1/user/active",
type : "GET",
data : "uid=" + readCookie("uid") + "&key=" + readCookie("key"),
success : function(data) {
alert(JSON.stringify(data));
$('#usertable').dataTable({
"sAjaxDataProp": JSON.stringify(data),
// "bProcessing": true,
"aoColumnDefs": [
{
"mDataProp": "acid",
"aTargets": [0]
},
{
"mDataProp": "firstname",
"aTargets": [1]
},
{
"mDataProp": "lastlogin",
"aTargets": [2]
},
{
"mDataProp": "lastname",
"aTargets": [3]
},
{
"mDataProp": "username",
"aTargets": [4]
}
],
// "sDom": 't<"dataTables_footers_dash"ip>',
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 10,
"bAutoWidth": false,
"bJQueryUI": true,
});
// $('#usertable').dataTable({
// "aaData": JSON.stringify(data),
// "aoColumnDefs": [{ "mDataProp": "acid" },
// { "mDataProp": "firstname"},
// { "mDataProp": "lastlogin"},
// { "mDataProp": "lastname"},
// { "mDataProp": "username"}
// ]
// });
},
error : function(data){
location.replace("500.html");
}
});
});
[/code]
JSON Returned by the REST Call is given below
[code]
{"tUsers":{"acid":"ccd6687e-32ab-11e1-af7e-992b0cb8782f","firstname":"Jonathan","lastlogin":"2012-01-17 18:42:46.0","lastname":"Keshrew","username":"harish@mailme.com"}}
[/code]
Most of the examples use either use a text file to load the data or run some PHP file on the server side. In our case all the transactions with the server happens using a token exchange to authorize it self. I'm not even sure whether i'm doing the right thing, any pointer to this kind of use case is really appreciated.
Thanks in advance.
This discussion has been closed.