Reputation: 33
I want to get access to json api objects using jquery:
"schedule":{"time":"22:00","days":["Wednesday","Thursday"]}
and i'm using this jquery code to get time data:
jQuery.getJSON("http://api.tvmaze.com/lookup/shows?imdb=" + co + "", function(data) {
jQuery.each(data, function(key, val) {
jQuery('input[name=' + key + ']').val(val);
if (key == "schedule") {
var tim = "";
jQuery.each(data.schedule, function(i, item) {
tim += item.time;
});
jQuery('#schedule_time').val(tim);
}
});
but nothing will show in output!
please help!
"network":{"id":128,"name":"KBS2","country":{"name":"Korea, Republic of","code":"KR","timezone":"Asia/Seoul"}}
Upvotes: 0
Views: 58
Reputation: 5766
if (key == "schedule") {
// val == {"time":"22:00","days":["Wednesday","Thursday"]}
jQuery('#schedule_time').val(val.time);
}
Since you already have access to the result of schedule, you don't need to create another loop. Just access the time directly.
Upvotes: 1