Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82053

How do I display data if that data is a nested object of the returned data?

$
0
0

So I have an ajax call that is returning data that contains two objects at the root. One is LastRefresh which is just the number of ticks and I'm not using it with my DataTable but I am using elsewhere. The other is a list of strings (SKUs) which I want to display in a DataTable. The data comes back fine but I haven't been successful yet in having datatables use the nested object called SKUs.

          fbaSKUTable = $('#fbaSKUs').DataTable({
                ajax: {
                    'url': '/api/FBA/RefreshSKUS',
                    'dataSrc': 'skuData',
                    'type': 'GET',
                    'success': function (data) {
                        skuData = JSON.stringify(data.SKUs);
                        storage.setItem("lastRefresh", JSON.stringify(data.LastRefresh));
                        storage.setItem("fbaSKUs", JSON.stringify(data.SKUs));
                    },
                    'failure': function (data) {
                        console.log('failure');
                    }
                },
                "columns": [
                    {"SKU": "SKU"}
                ]
            });

Here is some sample data

{"LastRefresh":"636826452200968391","SKUs":[{"SKU":"AB-BROWN"},{"SKU":"ZAR-FEO1"},{"SKU":"ZZZ-FROST"}]}

Viewing all articles
Browse latest Browse all 82053

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>