You're not trapping the form submission to ensure it happens via Ajax, so 
instead the form ends up being submitted to the URL of the parent page, so 
it doesn't get processes. If you want to include a form via Ajax, it will 
be much easier to put the form in LOAD(..., ajax=True), which will 
automatically handle trapping the form submission.

Anthony

On Sunday, November 15, 2015 at 10:03:26 PM UTC-5, lucas wrote:
>
> alright, so in a view i have:
>
> {{block head}}
> <script type="text/javascript">
> function clk_form(tidi) {
>     if (tidi != 0) {
>         jQuery('div#form').css('display','block');
>         ajax('/cs/default/ajaxTask?tidi='+tidi, [], 'form');
>     } else {
>         jQuery('div#form').css('display','none');
>         jQuery('div#form').html('');
>     }
>     return false;
> }
> </script>
> {{end}}
>
> <a onclick="clk_form(-1)" title="Create/Assign New Task" class="btn mtt" 
> style="font-size:14pt;"><b>New Task</b></a>
> <a onclick="clk_form(0)" title="Hide Task Entry Form" class="btn mtt" ">No 
> Form</a>
>
> <br /><div id="form" style="float: none;">
> </div>
>
> where i am trying to pull in the form asynchronously and that part works 
> fine when i press the New Task link/button.  and under the controller i 
> have:
>
> def ajaxTask():
>     try:
>         tidi = int(request.vars.tidi)
>     except:
>         tidi = 0
>     frm = None
>     if tidi and (tidi <> 0):
>         if (tidi == -1):
>             tidi = None
>         frm = SQLFORM(tTask, record=tidi, showid=False, 
> _action=URL(f='ajaxTask', args=[XML('#')]))
>         if frm.process(onvalidation=chk_task).accepted:
>             response.flash = 'Task Added/Updated %i' % (frm.vars.id)
>             #redirect(URL(f='tasks'))
>         elif frm.errors:
>             response.flash = 'Insert/Edit Errors'
>     return frm
>
> so, as i said the form pulls up fine and fills in the DIV.  but when i 
> submit the form, it all just sort of goes blank.  i would like it to commit 
> the insert/edit to the database and then clear the form under the DIV, 
> maybe leave a message of success under the response.flash or the DIV, and 
> leave the rest of the form untouched and unrefreshed.  does that make sense?
>
> thanx in advance, lucas
>

-- 
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.

Reply via email to