Files
web2py/applications/welcome/views/generic.jsonp
Massimo Di Pierro d421c1321b initial commit
2011-11-22 23:30:42 -06:00

16 lines
510 B
Plaintext

{{
###
# response._vars contains the dictionary returned by the controller action
###
try:
from gluon.serializers import json
result = "%s(%s)" % (request.vars['callback'], json(response._vars))
response.write(result, escape=False)
response.headers['Content-Type'] = 'application/jsonp'
except (TypeError, ValueError):
raise HTTP(405, 'JSON serialization error')
except ImportError:
raise HTTP(405, 'JSON not available')
except:
raise HTTP(405, 'JSON error')
}}