我正在使用开放天气地图 api web 服务进行 ajax 调用,以便使用纬度和经度获取当前天气,问题是相同的调用在我的正常 php 文件夹中工作,但在我的 phongap 应用程序中不起作用。我的ajax调用如下图
$.ajax({
type : "GET",
dataType: "jsonp",
url : "http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139",
}).done( function(msg){
var response = JSON.stringify(msg);
var parsedResponse = JSON.parse(response);
alert(parsedResponse.main.temp_min);
});
});
我试过没有dataType: "jsonp"
尝试将其更改为"json"
但根本不起作用。请帮助我,因为我目前陷入困境。
您是否已将 config.xml 中的 url 列入白名单?
<access origin="http://api.openweathermap.org" />
阅读更多:http://docs.phonegap.com/en/3.0.0/guide_appdev_whitelist_index.md.html#Domain%20Whitelist%20Guide
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)