vendredi 1 juillet 2016

How can I get a value from the second object that returns from AJAX call

The data object has 2 object in each object has multiple arrays I want to get the value from the second object of the second array

$.ajax({

            type: 'GET',
            url: 'api/First.getUniStructure',
            ContentType: 'application/json; charset=utf-8',
            dataType: 'json',

            success: function (data) {
                debugger;
                console.log(data);

                var collage = data[0].collages[0].Name;

                console.log(collage);

                var oTable = $('#exampleTable').DataTable({

                    data: data,

                    columnDefs: [
                        { targets: [2], data: data[0].collages[0].name }                            
                    ],

                    columns: [
                       { data: "ID" },
                       { data: "Name" },
                       { data: null }
                    ]

                });
            }

        });




Aucun commentaire:

Enregistrer un commentaire