MobileBlur

generic.load at [f6c84eb8e3]
Login

File applications/mobileblur/views/generic.load artifact fa6df36d52 part of check-in f6c84eb8e3


{{'''
# 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}}