MobileBlur

Artifact [fa6df36d52]
Login

Artifact [fa6df36d52]

Artifact fa6df36d5267e19ae4c65116cccb65a2dbd5f574:


{{'''
# License: Public Domain
# Author: Iceberg at 21cn dot com

With this generic.load file, you can use same function to serve two purposes.

= regular action
- ajax callback (when called with .load)

Example modified from http://www.web2py.com/AlterEgo/default/show/252:

def index():
    return dict(
		part1='hello world',
        	part2=LOAD(url=URL(r=request,f='auxiliary.load'),ajax=True))

def auxiliary():
    form=SQLFORM.factory(Field('name'))
    if form.accepts(request.vars):
        response.flash = 'ok' 
        return dict(message="Hello %s" % form.vars.name)
    return dict(form=form)

Notice:

- no need to set response.headers['web2py-response-flash']
- no need to return a string
even if the function is called via ajax.

'''}}{{if len(response._vars)==1:}}{{=response._vars.values()[0]}}{{else:}}{{=BEAUTIFY(response._vars)}}{{pass}}