jquery - How to load json array -
im trying load person data api : www.swapi.co . dont know how can load movies titles instead of api adress.
$(function(){ var list = $('.list'); var submit = $('.submit-people'); var people = '1'; submit.on('click',function(){ people++; list.empty(); $.ajax({ type: 'get', url: 'https://swapi.co/api/people/' + people + '/', success: function(data) { list.append('<li>name:' + data.name + '</li>'); list.append('<li>height:' + data.height + '</li>'); list.append('<li>mass:' + data.mass + '</li>'); list.append('<li>gender:' + data.gender + '</li>'); list.append('<li>movies:' + data.films + '</li>'); } }) })
my current code here : https://jsfiddle.net/wtpy71d7/2/
really or suggestions
this might you.
success: function(data) { ... for(var = 0; i< data.films.length; i++ ) $.ajax({ type: "get", url: data.films[i], success: function (data) { list.append('<li>movies:' + data.title + '</li>'); } }); } }
Comments
Post a Comment