I just finished tutorials for jquery ajax working with json. I had been able to create a ajax page. But to make things more complex. I have a json file that contain two types of array. example below(first objects belong to people array and the next two belong to newsfeed):
{
"people":[
{
"name":"John Constable",
"occupation":"CEO",
"location":"Toronto, Canada",
"division":"Health & Epidemics",
"profileImage":"",
"followers":123
},
{
"name":"Edward Monet",
"occupation":"Lead Developer",
"location":"Toronto, Canada",
"division":"Health & Epidemics",
"profileImage":"",
"followers":9923
}
]
},
{
"newsfeed":[
{
"Title":"Evaluations of disaster education programs for children",
"date":"Dec 10, 2015",
"tags":[
"disaster",
"tornado",
"risk management"
],
"division":"Health & Epidemics",
"Image":"",
"share":123
},
{
"Title":"UNISDR Annual Report 2014",
"date":"Dec 10, 2015",
"tags":[
"disaster",
"tornado",
"risk management"
],
"division":"Civil & Cyber Security",
"Image":"",
"share":123
}
]
}
My jquery code now is
$.getJSON( "ajax/result1-F.json", function( index ) {
var jasondata = [];
$.each(index, function( i, val ) {
$container1.append( "<div><ul>" + val.profileImage + "</ul><ul><li>"+ val.name + "</li><li>" + val.occupation +"</li><li>" + val.location + "</li><li>" + val.division + "</li></ul>" + "<ul><li> <button> FOLLOW </button> </li>" + "<li>" + val.followers + "</li><li>followers</li><ul></div>");
});
});
The container1 display all the info for the people's array.
Now I am stuck on how to display the newsfeed in a separate container2 simultaneously.
Can anyone point me to the correct direct? Thank you
peopleandnewsfeed? Isindexthe entire JSON object?