How to output data from JSON selectively?
-
Can't output inn, name and profile from json?
Writes - items.inn - undefined variable.
<script>$(document).ready(function() { $.ajax({ url: "https://xn--80aqahnxhf0b.xn----7sbhaopdx2angr0b9ina.xn--p1ai/data4tilda.php", dataType: 'json', success: function(result) { drawTable(result); } }); }); function drawTable(data) { // console.log('drawTable got data:', data); var html = ''; for (var i = 0; i < 10; i++) { html += '<tr><td>' + data[i].items.inn + '</td><td>' + data[i].items.name + '</td><td>' + data[i].items.profile + '</td></tr>'; } $('#table tbody').append(html); } </script>
JavaScript Benjamin Santiago, Sep 8, 2019 -
data is not an array in your JSON.
data.items - this is an array.Anonymous
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!