【发布时间】:2017-02-15 13:55:13
【问题描述】:
我需要根据用户提供的邮政编码搜索裁缝。我正在开发 Laravel 框架(第 5 版) 我可以通过 Ajax 成功检索结果,但尝试使用 json 管理它们时遇到问题。
这是我的脚本
<script type="text/javascript">
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
$(document).ready(function() {
//the button that activates the search search
$("#find-tailor").click(function() {
$.ajax({
url: 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=tailor+78577&key=AIzaSyBwb9nwAYMYm4cBkGzAFHmVeqwwoAQEIjI&sensor=true',
type: 'GET',
dataType: 'jsonp',
jsonpCallback: 'callback'
}).done(function(data) {
console.log(data);
});
});
});
</script>
//The script to inicializate the map
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB-amPYw4EvJGyYfY16HzhF2lqpw--FcHM&libraries=places&callback=initMap"> </script>
这是我得到的错误
Uncaught SyntaxError: Unexpected token :
但是,如果你输入到 url,它有 json 值 我怎样才能设法得到它们?
提前致谢
【问题讨论】:
标签: ajax google-maps laravel google-maps-api-3