我是JavaScript和jquery的新手......我一直在嘗試編寫一段簡單的代碼來使用天氣api提醒當前溫度。簡單天氣API當前溫度不工作
這裏是我到目前爲止有:
<script src="http://code.jquery.com/jquery-1.9.1.js"/>
<script>
var my_city="Washington,USA";
var my_key="8b0642a6c7133932132002";
var no_of_days=2;
// build URI:
var uri="http://free.worldweatheronline.com/feed/weather.ashx? q="+my_city+"&key="+my_key+"&format=json&no_of_days="+no_of_days+"&includeLocation=yes";
// uri-encode it to prevent errors :
uri=encodeURI(uri);
jQuery.get(uri,function(r){
current_temp_C =r.data.current_condition[0].temp_C;
alert(current_temp_C);
},"json");
</script>
然而,什麼也不顯示。如果有人能指出我要出錯的地方,請告訴我! 謝謝!
有跡象表明,有演示代碼等資源進行天氣http://codepen.io/jamesfleeting/筆/ wHism – Shanimal 2013-02-20 14:05:09
很棒的演示Shanimal,但我更多的是針對當前溫度的文本。謝謝! – InfiniDaZa 2013-02-20 14:13:28
下面是另一個http://codepen.io/anon/pen/bvyDh – Shanimal 2013-02-20 14:13:47