Question

I am working in extjs. I am working on finding of weather information functionality of given city. So in extjs4 controller i have code as-

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);
                }
            });
        });
    },

Its working correctly. But in the above function i want to set city name dynamically. suppose i have variable $cityname=pune.Then using this variable how i need to modify URL-"http://api.wunderground.com/api/4ab310c7d75542f3/geolookup/conditions/q/IA/pune.json" so that if weather information will be get retrieved depending upon city name that variable has. So how to change URL to set city names dynamically

Was it helpful?

Solution

use the params object passed to the request method: http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.data.JsonP-method-request

example:

Ext.data.JsonP.request({
     url : "http://api.wunderground.com/api/..",
     success : function(response) { ...},
     params:{foo:'bar'}
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top