Nanda
Nanda

Reputation: 35

how to show json array jquery in table

how to showing data url in table i try with my json

<script type="text/javascript">
    $(document).ready(function () {
        $.getJSON("coba.json",function (data) {
            var coba = '';
            $.each(data,function (key,value) {
                coba += '<tr>';
                coba += '<td>'+value.id+'</td>';
                coba += '<td>'+value.contact_first_name+'</td>';
                coba += '<td>'+value.contact_last_name+'</td>';
                coba += '<td>'+value.contact_gender+'</td>';
                coba += '</tr>';
            });
            $('#ayam').append(coba);
        });
    });
</script>

my json code https://pastebin.com/nxUkJqv5

Upvotes: 1

Views: 64

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72299

You need to use data.data inside $.each And code will work

Hard-coded working snippet:-https://jsfiddle.net/pqgo6rxa/

Note:- It's because data is the index which have all values that you want to append to table.

Upvotes: 1

Related Questions