【发布时间】:2013-12-21 08:34:46
【问题描述】:
我正在使用开放的天气地图 api 网络服务进行 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",但没有任何效果。请帮助我,因为我目前被困在这个问题上。
【问题讨论】:
-
我忘了补充一点,我没有得到任何响应,即如果我执行以下操作,我的手机会收到失败警报:.done(function(msg){ if(msg){ //做所有的字符串化和解析 } else{ alert("fail"); } });