Pergunta

I'm attempting to parse and loop through Google Calendar v3 API JSON data and all I get is undefined. I'm thinking there is just some minor problem with my syntax but can't seem to figure it out. I have working code for the v2 API using the google.com/calendar/feeds URL but v2 is being deprecated Nov 2014 so I need to get this v3 code working. Thank you

http://jsfiddle.net/qWfhP/1/

<div id='event-list'></div>
<script type="text/javascript">
$(document).ready(function() {
var url =  "https://www.googleapis.com/calendar/v3/calendars/mnjusq8qt3kh847kge772s9fmk%40group.calendar.google.com/events?singleEvents=true&key=AIzaSyD28KypP-wTD-AKZVECKL0WsxoXhJiYbys";
 $.getJSON(url, function(items) {
    for(i in items) {
        item = items[i];
        $("#event-list").append(item.summary + "<br/>");
    }
    });
});
</script>
Foi útil?

Solução

The items are in the items index in the returned array:

$.getJSON(url, function(data) {
    for(i in data['items']) {
        item = data['items'][i];
        $("#event-list").append(item.summary + "<br/>");
    }
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top