[SOLVED] How to extract, extra data element from incoming JSON dataset

[SOLVED] How to extract, extra data element from incoming JSON dataset

mi6crazyheartmi6crazyheart Posts: 2Questions: 0Answers: 0
edited April 2011 in General
Hello all u peoples, I'm not javascript/jquery professional but now i'm trying to learn this now. BDW, this is 1st time i'm using dataTables in one of my on going work & stuck at one point.

what i'm trying to do is , i'm extracting some 10 records from my DB table & send that to dataTables in JSON format. In this point, i'm adding 1 extra data element to that JSON dataset. Here is my JSON data set...

[code]
{"aaData":[["BANK.NIFTY","0.0225802448067765"],["CNX.100","0.0176875178055431"],["CNX.Infrastructure","0.00987051725306753"],["CNX.Midcap","0.00754608894906794"],["CNX.Nifty.Junior","0.0225802448067765"],["CNX.Realty","0.0175529168817758"],["CNXIT","0.0144913520550491"],["NIFTY","0.0196899602305007"],["NIFTY.MIDCAP.50","0.0115103829961685"],["S.P.CNX.500","0.0156648988410921"]],"timestmp":"2010-11-04 00:00:00"}
[/code]

Here d extra data element which i've added is : "timestmp":"2010-11-04 00:00:00"

So, now what i wanted to do is extract that timestamp value & resent that timestamp value again in POST methode. That's coz, according to my logic... i needed to check that timestamp value & according to that value i'll send my 10 set of record & return that to dataTables.

The javascript code which i'm using is this...

[code]
var timestmp = '';

$(function(){
render_table();
});

function render_table(){
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bDestroy": true,
"bServerSide": true,
"sAjaxSource": "http://localhost/kk-graph/index.php/table/insert_table_data",
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "item" : timestmp } );
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );

}
} );
} );
}
setInterval("render_table()", 5000 );
[/code]

Thx in advance :)
This discussion has been closed.