Slide 25
Slide 25 text
Copyright © 2011 Asial Corporation. All Rights Reserved. │ 25
STEP➁ Web APIの実行 スクリプトの実装
• js/app.jsの「 getWeatherData 」関数内に以下のコードを記述します。
$.ajax({
url: apiInfo.url,
timeout: 10000,
data: {
appid: apiInfo.id,
coordinates: location,
output: 'json'
}
})
.then(function(result) {
console.log(JSON.stringify(result));
var title = result.Feature[0].Name;
var weatherList = result.Feature[0].Property.WeatherList.Weather;
showResult(title, weatherList);
})
.catch(function(error) {
onError('通信エラーが発生しました');
});