本人调用了百度地图的API接口,在Firefox本地可以测试成功,而chrome失败,怎么回事,而将页面上传到github-pages中显示,在firefox设置解除保护,可以正常显示,但在chrome却不能显示,控制台信息如下:
4 Mixed Content: The page at 'https://lchreal6.github.io/fc...' was loaded over HTTPS, but requested an insecure script 'http://api.map.baidu.com/geoc...…3338585&location=23.0444612,113.3882067&output=json&pois=1&_=1474943338586'. This request has been blocked; the content must be served over HTTPS.
调用接口代码如下
$.getJSON('http://api.map.baidu.com/geocoder/v2/?ak=0FuoX30MFf7YMrdS5Wi9GGAcHBblKDuu&callback=?&location='+latitude+','+longitude+'&output=json&pois=1', function(res){
$("#location").html(res.result.addressComponent.city);
yourCurCity = res.result.addressComponent.city;
});
该怎样解决才能在chrome上正常显示。
伊谢尔伦2017-04-11 13:03:33
目测问题应该是你自己的网站是https
协议,而请求的目标接口是http
协议,所以会出现这个问题。
哈哈,打个广告,我自己写了个天气接口,不过只能查询国内的(https
协议,支持GET/POST
):
点我查询北京的天气
具体用法看这里-wiki