how i can get aaData object result ?

how i can get aaData object result ?

davisvasconcellosdavisvasconcellos Posts: 12Questions: 2Answers: 0

how i can get aaData result and put into array to populate another plugin like gmaps,highcharts ?
i have results like this:
{
"aaData": [
{
"name": "name1",
"values": "R$ 2778",
"totalUnidades": "188",
"dt_atual": "27/03/2007",
"coord": "-99.99,-99.99"
},
{
"name": "name2",
"values": "R$ 2916",
"totalUnidades": "120",
"dt_atual": "31/05/2008",
"coord": "-99.99,-99.99"
}
]
}

in datatables into:
"fnDrawCallback": function () {
// NEW ARRAY like [ [name1,R$ 2778] , [name2,R$ 2916] ... ]

// then call another plugin - highcharts,gmaps...
$('#myDiv').highcharts({ ...
series: [{
name: 'blabalbla,
data: [NEW ARRAY]
...
},

i thing this question is the same and very helpfull to others people.

thanks

Answers

  • XythantiopsXythantiops Posts: 4Questions: 0Answers: 0
    edited August 2014

    I am running into a similar issue, there are some fields like sSearch that I can access directly using $_GET (e.g. $_GET['sSearch']), but there are other variables that contain objects or arrays that I am unsure of how to access their data.

    "order":[{"column":"0","dir":"desc"}]

    I am using PHP and tried using json_decode to access it as both an object and as an associative array:

    ```php
    <?PHP
    // Object
    $obj = json_decode($_GET['order']);

    echo $obj->{'column'}; // Outputs null
    echo $obj->{'dir'}; // Outputs null

    // Associative array
    $arr = json_decode($_GET['order'],true);
    echo $arr['column']; // Outputs null
    echo $arr['dir']; // outputs null

    <?php > ``` ?>

    I even tried just exploding it in case it was being passed as a string:

    ```php
    <?PHP
    // Explodes $_GET['order'] into an array
    $arrExplode = explode(":",$_GET['order']);

    echo $arrExplode[0]; // Outputs null
    echo $arrExplode[1]; // Outputs null

    <?php > ``` ?>
  • XythantiopsXythantiops Posts: 4Questions: 0Answers: 0
    edited August 2014

    Ok, I figured out my problem:

    ```php
    <?PHP
    echo $_GET['order'][0]['column']; // Outputs 2
    echo $_GET['order'][0]['dir']; // Outputs asc

    <?php > ``` ?>
  • davisvasconcellosdavisvasconcellos Posts: 12Questions: 2Answers: 0

    understand.
    but my datatables works fine. i no need create 2 outputs from serverside. only get or convert actual response and put into fndwawcallback .

    :(

This discussion has been closed.