0
我試圖做一個ajax請求谷歌日曆API,但出了問題。 在這裏我有非常簡單的代碼,但我不明白爲什麼它不工作。ajax請求谷歌日曆api
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(確定)。任何幫助將不勝感激!
Here is screenshot我的ClientID。
AJAX跨域/來源不正常。應該從服務器進行呼叫。或者這可能工作,但從來沒有測試過:http://www.ajax-cross-origin.com/ –