My function is too long to paste here, but this is the (untested) relevant
lines.  I have jsonp callback working with jquery ajax.

def GET(self, method):
        args = web.input()
        web.header('Content-Type', 'application/json')
        payload = json.dumps({'a': 'foo'}) ' # or call some func that
return serialized data
        return "%s('%s')" % (args["callback"], payload)

I can't find my jquery example, but basically it executes the command you
got back.  callbackfunc(jsondata);



On Thu, Mar 7, 2013 at 12:03 AM, anh le <[email protected]> wrote:

> Hello,
>
> I think return jsonp is something like this:
> url: .../somepage?callback=bar
>
> class SomePage:
>     def GET(self):
>         callback = web.input(callback='default_callbackname')
>         web.header('Content-type', 'application/javascript')
>         data = json.dumps({'a': 'foo'}) ' # or call some func that return
> serialized data
>         content = str(callback) + '(' + data  + ')'
>         return content
>
> Just the quick outline I haven't test this yet.
>
>
> On Thu, Mar 7, 2013 at 2:44 AM, shlomo bauer <[email protected]>wrote:
>
>> I need to have one of my webpy services return jsonp
>>
>> serializing into a json string is easy enough.
>>
>> I can't wrap the response in the jquery callback value - and I have no
>> clue how to get the value.
>>
>> I can't find any documentation.
>>
>> Help.
>>
>> thanks
>> --
>> You received this message because you are subscribed to the Google Groups
>> "web.py" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/webpy?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/webpy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to