Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 向google日历api发出ajax请求_Javascript_Jquery_Ajax_Google Api - Fatal编程技术网

Javascript 向google日历api发出ajax请求

Javascript 向google日历api发出ajax请求,javascript,jquery,ajax,google-api,Javascript,Jquery,Ajax,Google Api,我试图向谷歌日历API发出ajax请求,但出现了一些问题。 这里我有非常简单的代码,但我不明白为什么它不工作 var mykey = 'my server key'; // I am using here server key(which I created in credentials in console.developers.google.com) Maybe I am using wrong version?! I've tried browser key, but it didn't

我试图向谷歌日历API发出ajax请求,但出现了一些问题。 这里我有非常简单的代码,但我不明白为什么它不工作

var mykey = 'my server key'; // I am using here server key(which I created in credentials in console.developers.google.com) Maybe I am using wrong version?! I've tried browser key, but it didn't help me.

var calendarid = 'my client_id'; // here I am using VALID clientId, which I created in my project in developer console. Below this code I attached screen.

$.ajax({
    type: 'GET',
    url: encodeURI('https://www.googleapis.com/calendar/v3/calendars/' + calendarid+ '/events?key=' + mykey),
    dataType: 'json',
    success: function (response) {
        //console.log('Nice!')
    },
    error: function (response) {
        //console.log('Bad!')
    }
});
我总是在浏览器控制台中出现错误404(OK)。任何帮助都将不胜感激


对于my ClientID。

在联系日历API之前,您需要使用OAuth显示登录提示并获取访问令牌。最简单的方法是使用

AJAX跨域/源不正常。应该从服务器进行调用。或者这可能有效但从未测试过: