2011-02-09 3 views
-1

こんにちは私は天気のAPIが動作するように見えません。私はjqueryとjsonを使用していますが、コードは下ですが、私は一日中それを見ていて、どこが間違っているのか理解できません。誰かが下に目を投げて何が起こっているか教えてください。 Daveさん、ありがとうございます。 APIを動作させることができません。助けてください!

$.get('http://www.worldweatheronline.com/feed/weather.ashx?q=Auckland,New+Zealand&format=json&num_of_days=2&key=7677dba721211420113101', function(data, textStatus) 
    { 
    alert('Status is '+textStatus); 
    alert('JSON data string is: '+data); 

    // this will give us an array of objects 
    var weather = JSON.parse(data); 

    // iterate over public_tweets 
    for(var x=0; x < weather.length; x++) { 
     var twt = weather[x]; 
     var elm = weather.current_condition.temp_C; 
     alert('Current Temp is:'+elm); 
     }); 

答えて

1

あなたのループが終了ブラケットを持っていないために:

$.get('http://www.worldweatheronline.com/feed/weather.ashx?q=Auckland,New+Zealand&format=json&num_of_days=2&key=7677dba721211420113101', function(data, textStatus) 
    { 
     alert('Status is '+textStatus); 
     alert('JSON data string is: '+data); 

     // this will give us an array of objects 
     var weather = JSON.parse(data); 

     // iterate over public_tweets 
     for(var x=0; x < weather.length; x++) 
     { 
      var twt = weather[x]; 
      var elm = weather.current_condition.temp_C; 
      alert('Current Temp is:'+elm); 
     } 
    }); 
関連する問題