0

I can't access json nested with jquery.

This is my code:

<div class="mypanel"></div>
<script>
$.getJSON('http://www.json-generator.com/api/json/get/cfdUjFmWoO?indent=2', function(data) {
        var text = `Date: ${data.date}<br>
                    Time: ${data.time}<br>
                    Unix time: ${data.milliseconds_since_epoch}`
        $(".mypanel").html(text);
});
</script>
gaurav
  • 657
  • 4
  • 11
ajprs28
  • 63
  • 3
  • 14
  • 1
    Possible duplicate of [How do I parse JSON with getJSON.](https://stackoverflow.com/questions/7001168/how-do-i-parse-json-with-getjson) – Script47 Aug 25 '17 at 13:19
  • 1
    Firstly, `data` in the response is an array so you need to access it by index. Secondly, none of the objects in that array have properties with the names you've used. You can check the response format here: http://jsfiddle.net/mb89fks1/ – Rory McCrossan Aug 25 '17 at 13:22
  • Possible duplicate of [How to access nested JSON data](https://stackoverflow.com/questions/9463233/how-to-access-nested-json-data) – Shiladitya Aug 25 '17 at 13:35

0 Answers0