Getting JSON object
Getting JSON object
sulest
Posts: 2Questions: 0Answers: 0
Hello,
I have a bit of silly question. How to get whole JSON response.
Why? Because I'm trying to create table headers that will be selectboxes so my code is:
My JSON looks like this
[code]
{"aaData":
[
["INT","INT","STRING","STRING","STRING","STRING","STRING"],
["INT","INT","STRING","STRING","STRING","STRING","STRING"],
["INT","INT","STRING","STRING","STRING","STRING","STRING"]
],
"sEcho":1,
"iTotalRecords":"19",
"iTotalDisplayRecords":"9",
"orderNumbers":["1","3","6","7"],
"productNames":["NAME","OTHER NAME","NNNAME"]
}
[/code]
[code]
oTable = $('.datatable').dataTable({
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"iDisplayLength" : 30,
"iMaxPageLength" : 100,
"bScrollInfinite": true,
"sAjaxSource": URL,
"aaSorting": [[0,"desc"]],
"aoColumnDefs":[
{"bSearchable": false, "bVisible": false, "aTargets":[0]},
{"bSortable": false, "aTargets":[1,2,3,4,5,6]}
],
"fnHeaderCallback": function(nHead, aaData, iStart, iEnd, aiDisplay){
//how to call OBJ.orderNumbers or OBJ.productNames
//I NEED JSON RESPONCE HERE
//SO I WILL BE ABLE TO CHANGE SOME STUF IN TABLE HEADER
}
[/code]
I have information about how to pull aditional request and get my aditional data, but I do not want to make 2 requests every time.
I need to get orderNumbers and productNames
Thanks
I have a bit of silly question. How to get whole JSON response.
Why? Because I'm trying to create table headers that will be selectboxes so my code is:
My JSON looks like this
[code]
{"aaData":
[
["INT","INT","STRING","STRING","STRING","STRING","STRING"],
["INT","INT","STRING","STRING","STRING","STRING","STRING"],
["INT","INT","STRING","STRING","STRING","STRING","STRING"]
],
"sEcho":1,
"iTotalRecords":"19",
"iTotalDisplayRecords":"9",
"orderNumbers":["1","3","6","7"],
"productNames":["NAME","OTHER NAME","NNNAME"]
}
[/code]
[code]
oTable = $('.datatable').dataTable({
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"iDisplayLength" : 30,
"iMaxPageLength" : 100,
"bScrollInfinite": true,
"sAjaxSource": URL,
"aaSorting": [[0,"desc"]],
"aoColumnDefs":[
{"bSearchable": false, "bVisible": false, "aTargets":[0]},
{"bSortable": false, "aTargets":[1,2,3,4,5,6]}
],
"fnHeaderCallback": function(nHead, aaData, iStart, iEnd, aiDisplay){
//how to call OBJ.orderNumbers or OBJ.productNames
//I NEED JSON RESPONCE HERE
//SO I WILL BE ABLE TO CHANGE SOME STUF IN TABLE HEADER
}
[/code]
I have information about how to pull aditional request and get my aditional data, but I do not want to make 2 requests every time.
I need to get orderNumbers and productNames
Thanks
This discussion has been closed.
Replies
[code]
var json = $.parseJSON( this.fnSettings().jqXHR.responseText );
[/code]
in the header callback.
DataTables saves the XHR object, but not the JSON reply. An oversight that - I'll add it in to the new API for 1.10.
Allan
Allan