私は JavaScript と jquery を初めて使用します...天気 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>
ただし、何も表示されません。誰かが私が間違っている場所を指摘できる場合は、教えてください! ありがとう!