hi,
i've tried to learn from
http://web2py.com/book/default/chapter/10#Ajax-Form-Submission,
is it possible to edit the ajax form submission?
e.g.
=== db.py ===
db = DAL('sqlite://db.db')
db.define_table('post', Field('your_message', 'text'))
db.post.your_message.requires = IS_NOT_EMPTY()
=== default.py ===
def index():
return dict()
def new_post():
form = SQLFORM(db.post)
if form.accepts(request.vars, formname=None):
results = db().select(orderby = ~db.post.id)
return DIV(results)
elif form.errors:
return TABLE(*[TR(k, v) for k, v in form.errors.items()])
=== default/index.html ===
{{extend 'layout.html'}}
<div id="target"></div>
<form id="myform">
<input name="your_message" id="your_message" />
<input type="submit" />
</form>
<script>
jQuery('#myform').submit(function() {
ajax('{{=URL('new_post')}}',
['your_message'], 'target');
return false;
});
</script>
i've already tested it and return null, did anyone knows how to do
ajax form submission that return the updated list value.
thank you so much.