Reading data outside the 'data' object

Reading data outside the 'data' object

smerchantsmerchant Posts: 4Questions: 2Answers: 0

How do I read the data which is outside the data object e.g. client Id and time element which is not a column but just information about the dataset.

Thanks

    {   
        "client_id":"ddddd",
        "time":"16:00m",
        "data": [
            {
                "Book": "Mr Smith",
                "Author": [],
                "Description": "",
    }}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    It depends where you want to get the data? Assuming you are using ajax to get the JSON, then you can use ajax.json() to get the response from the server at some other point.

    Allan

  • smerchantsmerchant Posts: 4Questions: 2Answers: 0

    I am getting a json from GitHub raw data and yes I am using ajax url option. So are you suggesting that I can do something like below to get data var json?

    table.on( 'xhr', function () {
        var json = table.ajax.json();
        alert( json.data.length +' row(s) were loaded' );
    } );
    
  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    Yep, that would do it - see here: http://live.datatables.net/ruhuguwu/3/edit

    Colin

  • smerchantsmerchant Posts: 4Questions: 2Answers: 0

    Thanks Colin. That's what I did.

This discussion has been closed.