高德地图web服务api怎么用
http://restapi.amap.com/v3/assistant/inputtips?output=json&city=0577&keywords= 招商银行&key=mykey
用浏览器直接访问能得到一串json,可是用ajax什么都没有。。
$.ajax({
url:'http://restapi.amap.com/v3/assistant/inputtips?output=json&city=0577&keywords=招商银行&key=0b00174f6f8ab4ca8d350ac0da105bb9',
type:'get',
success:function(data){
console.log(data);
},
error:function(data){
console.log(data);
}
})
$.get('http://restapi.amap.com/v3/assistant/inputtips?output=json&city=0577&keywords=招商银行&key=0b00174f6f8ab4ca8d350ac0da105bb9',function(data){
alert(data)
})
2个方法都不行,救命~~~
MAKUBEX
9 years, 3 months ago
Answers
$.ajax({
url:'http://restapi.amap.com/v3/assistant/inputtips?output=json',
data: {
city: 0577,
keywords:"招商银行",
key:"0b00174f6f8ab4ca8d350ac0da105bb9"
},
type:'get',
dataType:'jsonp',
success:function(data){
console.log(data);
},
error:function(data){
console.log(data);
}
})
我把几个参数拿出来放到data中,试了一下,好像有跨域问题,然后又加了dataType,发现成功输出
555555
answered 9 years, 3 months ago