2

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>
ScottEH
  • 37
  • 1
  • 9

1 Answers1

6

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/>");
    }
});
Vinicius Braz Pinto
  • 8,209
  • 3
  • 42
  • 60
  • Thank you very much Vinicius Pinto! I thought it might have something to do with the returned values being in an array but wasn't 100% positive of that and then didn't now how to access data within the array. – ScottEH Apr 17 '14 at 02:33