I am building Dojo mobile app. I have a Json file like:
{
Introduction:
[
{
title: "Introduction",
toolbar: "Page 1",
content: "cont, aabitant morbi tristique..."
},
{
title: "Introduction",
toolbar: "Page 2",
content: "contesent vel nisi ipsum..."
}
],
Services:
[
{
title: "services",
toolbar: "Page 1",
content: "Cras adipiscing sapien nec..."
}
]
}
Following code prints introduction as written in title
dojo.xhrPost({
url: "diet.json",
handleAs: "json",
load: function(response) {
console.log(response.Introduction[0].title);
}
});
I am able to get inner data. How can I get first headings i.e.
- Introduction
- Services
So you want the first title in each object in your response?
Of course this assumes there’s at least one element in each array in the response. If some may be empty, you’d want something like this: