I think with that code, if you type the url on the browser:
localhost:8080/getcities?foo=4&tg_format=json
it'll try to give you text output because of @expose()

try this:

localhost:8080/getcities.json?foo=4&tg_format=json




b vivek yazmış:
Hi..!
Well a very novice question from a newbie...I have an action which is supposed to return the name of cities in json format when a country id is supplied to it.The action is as below:-

    @expose()
    @expose("json")
    def getcities(self,**datas):
        countryid=datas['foo']
citylist=[city.name <http://city.name> for city in DBSession.query(City).filter_by(country_id=countryid)]
        return dict(citylist1=citylist)

1.it <http://1.it> is sent the country id by a get request(ajax) like "getcities?foo=4". 2. But to test the output of the action when I go to the browser and type "localhost:8080/getcities?foo=4" i get one thing printed on the screen as citylist1.The same happens when i use "localhost:8080/getcities?foo=4&tg_format=json". 3. I am sure I am doing something very silly here but please help

regards
Vivek

--
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to