내가 아래에있는 내 loaded10DayForcast 기능에 십일 예측을 얻으려고하지만 난 다음 오류 받고 있어요 : 내가 따라 올바른 API 호출을 모르는처럼날씨 지하 10Day 예측 API
Cannot read property 'simpleforecast' of undefined
보인다 여기에서 : http://www.wunderground.com/weather/api/d/docs?d=data/forecast10day
현재 조건을 올바르게 표시 할 수 있기 때문에 이상합니다. 코드 예제에서
//Get the current weather conditions
function getCurrentConditions(text) {
console.log("\n")
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.DONE) {
var jsonObject = eval('(' + doc.responseText + ')');
loadedCurrentConditions(jsonObject);
}
}
doc.open("GET", "http://api.wunderground.com/api/KEY/forecast/geolookup/conditions/q/"+ text + ".json");
doc.send();
}
//Get the 10 Day Forcast
function get10DayForcast(text) {
console.log("\n")
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.DONE) {
var jsonObject = eval('(' + doc.responseText + ')');
loaded10DayForcast(jsonObject);
}
}
doc.open("GET", "http://api.wunderground.com/api/KEY/forecast10day/q"+ text + ".json");
doc.send();
}
//Display to console
function showRequestInfo(text) {
console.log(text)
}
function loadedCurrentConditions(jsonObject)
{
showRequestInfo("Current Temp F:" + jsonObject.current_observation.temp_f);
showRequestInfo("Weather Description:" + jsonObject.current_observation.weather);
showRequestInfo("Icon:" + jsonObject.current_observation.icon);
}
function loaded10DayForcast(jsonObject)
{
showRequestInfo("Today High Temp F:" + jsonObject.forecast.simpleforecast.forecastday.Forecast[0].low.fahrenheit);
}