使用JQuery解析Google Calendar v3 API JSON [英] Parse Google Calendar v3 API JSON with JQuery

查看:173
本文介绍了使用JQuery解析Google Calendar v3 API JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解析和循环遍历Google Calendar v3 API JSON数据,但是我得到的所有信息都是不确定的.我在想我的语法只有一些小问题,但似乎无法弄清楚.我有使用google.com/calendar/feeds URL的v2 API的有效代码,但是v2已于2014年11月弃用,因此我需要使此v3代码正常工作.谢谢

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>

推荐答案

项目位于返回数组的items索引中:

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/>");
    }
});

这篇关于使用JQuery解析Google Calendar v3 API JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆