How to read object like train in this json ...i was able to read route but object f json not able to

How to read object like train in this json ...i was able to read route but object f json not able to

rahul mahalerahul mahale Posts: 1Questions: 0Answers: 0

{
"response_code": 200,
"route": [
{
"no": 1,

    },
    {
        "no": 2,

    },
    {
        "no": 3,

    }
],
"train": {
    "number": "152526",

    "days": [
        {
            "day-code12": "kak",
            "ru2s": "Nam"
        },
        {
           "day-code12": "kak",
            "ru2s": "Nam"
        },

    "classes": [
        {

            "class-code": "AB"
        },
        {

            "class-code": "CC"
        },

    ]
}

}

$(document).ready(function () {

          $('#btn1').on(click, function () {

getData();
});
});

function getData() {
var n = document.getElementById("number").value;
var url = "url";
// var url = "http://drive.google.com/file/d/0B3WFeMArz8bUSDFTbnBOMlFVd2M/view?usp=sharing ";
$.ajax({

    url:url,
    async: false,

    dataType: 'json',
    success: function (data) {
    //alert(JSON.stringify(data));

     //   var trainName = data.train.name;
    //  $('#trainName').empty();
    //  $('#trainName').append(trainName);



        displayInfo(data);


    },
    error: function (){
        alert("fail in getting data");

    }

});

}

function displayInfo(data) {

var table = $('#trainRoute').dataTable({
    "aaData": data.train,

    "info": false,
    "search": false,
    "sort": false,
    'iDisplayLength': 100,
    'bDestroy': true,

    "columns": [
{ "mData": "number" },



    ]
});

}

This discussion has been closed.