Your solution is just fine. Python JSON module is only for
serialization/deserialization.

Maybe you should add some validation for "callback" field.

On Mar 11, 12:04 am, Philip Tait <[email protected]> wrote:
> After some experimenting, I was able to get JSONP working, but I'm
> wondering if there is a cleaner way of doing it than what I came up
> with:
>
> In my GET() method, I grab the name of the callback function:
>
>     self.cbfn = form.value['callback']
>
> then when I return the data to the server, I have:
>
>     web.header('Content-Type', 'application/javascript')
>     return "%s(%s)" % (self.cbfn, json.dumps(ret_data))
>
> Is this the "right" way to do it? It's working OK, I was just
> surprised not to find any support in the JSON module.
>
> Philip

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to