i am using the open weather map api webservice to make an ajax call inorder to get the current weather using the latitude and longitude the problem is the same call works in
var weather = ""
var ajax_call = "http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139";
$.ajax({
type: "GET",
url: ajax_call,
dataType: "jsonp",
success: function(response){
$.each(response, function(key, value) {
//alert(key+"====="+value)
if(key == "coord"){
weather += 'coord';
$.each(value, function(key, value) {
if(key == "lon")
weather += 'lon: '+value+'';
if(key == "lat")
weather += 'lat: '+value+'';
});
}
if(key == "weather"){
weather += 'weather';
$.each(value, function(key, value) {
if(value.id)
weather += 'id: '+value.id+'';
if(value.main)
weather += 'main: '+value.main+'';
if(value.description)
weather += 'description: '+value.description+'';
});
}
if(key == "main"){
weather += 'main';
$.each(value, function(key, value) {
if(key == "temp")
weather += 'temp: '+value+'';
if(key == "temp_min")
weather += 'temp_min: '+value+'';
if(key == "temp_max")
weather += 'temp_max: '+value+'';
if(key == "pressure")
weather += 'pressure: '+value+'';
if(key == "sea_level")
weather += 'sea_level: '+value+'';
if(key == "grnd_level")
weather += 'grnd_level: '+value+'';
if(key == "humidity")
weather += 'humidity: '+value+'';
});
}
});
alert(weather)
console.log(weather)
}
}).done(function() {
})
- 热议问题