1

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

4
  • whats your error? Commented Sep 25, 2018 at 7:29
  • data not show ... im use url form api Commented Sep 25, 2018 at 7:44
  • you missed json.parse(data) for your data Commented Sep 25, 2018 at 7:54
  • @AhmedSunny no,$.getJSON do it automatically Commented Sep 25, 2018 at 8:00

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@Nanda i don't know laravel. Sorry. You can ask new question for requirement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.