2013-04-20 25 views
0

我正在使用extjs。我正在努力尋找特定城市的天氣信息功能。所以在extjs4控制器我有代碼 -在extjs中如何更改URL以動態設置城市名稱

getWeather : function() { 
     $obj = 'pune'; 
     Ext.require('Ext.data.JsonP', function() { 
      Ext.data.JsonP.request({ 
       url : "http://api.wunderground.com/api/4ab310c7d75542f3/geolookup/conditions/q/IA/pune.json", 
       success : function(parsed_json) { 
        var location = parsed_json['location']['city']; 
        var temp_c = parsed_json['current_observation']['temperature_string']; 
        alert("Current temperature in " + location + " is: " 
          + temp_c); 
       } 
      }); 
     }); 
    }, 

它的工作正常。但在上面的函數中,我想動態設置城市名稱。假設我有變量$ cityname = pune.然後使用這個變量,我需要修改URL-「http://api.wunderground.com/api/4ab310c7d75542f3/geolookup/conditions/q/IA/pune.json」,這樣如果天氣信息將根據城市名稱被檢索到,那麼這個變量有。那麼如何改變URL設置城市名稱動態

回答

相關問題