I usually have a controller like this: def update_or_insert_thing(): response.view ='generic.json' ret = None if request.vars: if request.vars.id: request.vars.id = int(request.vars.id) ret = db(db.thing.id == request.vars.id).validate_and_update (**request.vars) else: ret = db.thing.validate_and_insert(**request.vars) if ret and ret.errors: response.flash = T('Validation Errors') return {'id': request.vars.id or ret.id, 'errors': ret. errors} return {'id': request.vars.id or ret.id, 'errors': []} return {}
Then all you need is to post to it using your dict as the data. Something like this $.ajax( { url: "{{=URL('default', 'update_or_insert_thing')}}", method: 'POST', data: {"id":3, "firstName":"John", "lastName":"Doe"} dataType: 'json' } ).done(function(data) {... // Here you should deal with validation errors -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.