下面是代碼有誰能告訴我爲什麼我無法從google apis獲取城市列表?
<script>
$.ajax({
url: "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=(cities)&language=pt_BR&key=AIzaSyA8FpY17IMXOcKg7Zwzdv2GdTQLR3OnTTk",
type: "GET",
dataType: 'jsonp',
cache: false,
success: function (response) {
console.log(response);
}
});
</script>
後,我執行了以上我總是得到這個錯誤。
maps.googleapis.com/maps/api/place/autocomplete/json?input=Vict&types=(citi…nTTk&callback=jQuery1111044755223696120083_1455461549950&_=1455461549951:2 Uncaught SyntaxError: Unexpected token :
插件該URL(它是一個在地圖的JavaScript-API庫)進入一個新的瀏覽器標籤,你會看到問題。 – Pointy
我已經嘗試使用https。無論如何,我會更具體地改變顯示錯誤的問題。 –
這意味着您無法從瀏覽器訪問該URL。您必須從服務器上的代碼執行此操作。 – Pointy