Below is the sample json data that i took from my api in html page,
[{
"id": 1,
"name": "rele",
"location": "bedroom",
"posts": [
{
"id": 2,
"description": "hi"
}
]
}]
Below is the jquery,
<script type = "text/javascript" >
$(document).ready(function() {
$("#message").click(function(event){
$.getJSON('http://localhost:8080/jpa/device', function(jd) {
$('.tblForm #result').html('<p> ID: ' + jd.posts.id + '</p>');
$('.tblForm #result').append('<p>Description : ' + jd.posts.description+ '</p>');
});
});
});
</script>
i could able to fetch name
and location
value but not posts.description
.
I am getting an error : "Property or field 'description'
cannot be found"