Google日历不会返回有效的json文件

时间:2014-07-21 09:53:44

标签: javascript json angularjs calendar

我们正在与AngularJS建立一个网站。我们需要谷歌日历活动。 我尝试从Google Calandar加载数据。

在这里你可以找到json文件:http://www.google.com/calendar/feeds/nmk97b3l07ncb9f9h5ap5ffo2c@group.calendar.google.com/public/full?alt=json-in-script&callback=insertAgenda&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true

但是Angulair并不认为它是一个json文件。

有没有办法将其作为json文件?

1 个答案:

答案 0 :(得分:1)

insertAgenda是jsonp-callback-parameter。

试试这个:

var url = 'http://www.google.com/calendar/feeds/nmk97b3l07ncb9f9h5ap5ffo2c@group.calendar.google.com/public/full?alt=json-in-script&callback=insertAgenda&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true';

$.ajax({
   type: 'GET',
    url: url,
    async: false,
    jsonpCallback: 'insertAgenda', //The callback parameter in Google Calendar response
    contentType: "application/json",
    dataType: 'jsonp',
    success: function(json) {
       console.dir(json);
    }
});

DEMO

相关问题