我无法向 Google Places API 发送 AJAX 请求。代码:
$.ajax({
type: 'GET',
url:'http://maps.googleapis.com/maps/api/place/textsearch/json?',
dataType: 'json',
data: {
'query' : "restaurants+in+" + cityname,
'key' : MyPublicKey,
'sensor' : "false"
},
success: function(restaurans) {
console.log(restaurants);
}
});
我做错了什么?
最佳答案
我猜REST API不能这样使用(我猜原因之一应该是CORS)
Looking to use this service in a JavaScript application? Check out the Places Library of the Google Maps API v3.
这应该会引导你
https://developers.google.com/maps/documentation/javascript/places
及其“文本搜索请求”部分提供了 Google 文本搜索服务对象的示例
关于jquery - Ajax 和 Places API 获取请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19975016/