[web2py] Re: web2py: How to execute further code after ajax call

2022-08-13 Thread Anthony
FYI, already answered at https://stackoverflow.com/a/73338318/440323.

On Saturday, August 13, 2022 at 10:37:06 PM UTC-4 JPlata wrote:

> 
>
> I have two dropdown/select widgets on a form. I am trying to set the 
> options of the second select through an ajax call in jQuery, and then 
> execute further code. The ajax call is successful and correctly sets the 
> second select options, but it seems the code after the ajax call is not 
> executed at all. How to correct this?
>
> view:
>
>
> {{extend 'layout.html'}}` {{=title}} /This is the 
> library/edit_user.html template {{=grid}}  
> jQuery("#no_table_region_id").change(function(){ region_id = $(this).val(); 
> branch_id = jQuery('#no_table_branch_id').val(); ajax("{{=URL('library', 
> 'branches')}}" + '?region_id=' + region_id, [], 'no_table_branch_id'); 
> jQuery('#no_table_branch_id').val(branch_id); # this does not execute }); 
> jQuery(document).ready(function(){ // todo: solve the unsettable branch_id 
> jQuery("#no_table_region_id").change(); });  
>
> controller:
>
> def branches(): if request.vars.region_id: branches = 
> db(db.branch.region_id==request.vars.region_id).select(db.branch.ALL) 
> ops1 = [''] ops = ops1 + [f" 'id']}>{i['branch_name']}" for i in branches] else: ops = '' 
> return ops 
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4b1863dc-4f9b-41d8-9d10-2c9e2c971662n%40googlegroups.com.


[web2py] web2py: How to execute further code after ajax call

2022-08-13 Thread JPlata
 

I have two dropdown/select widgets on a form. I am trying to set the 
options of the second select through an ajax call in jQuery, and then 
execute further code. The ajax call is successful and correctly sets the 
second select options, but it seems the code after the ajax call is not 
executed at all. How to correct this?

view:


{{extend 'layout.html'}}` {{=title}} /This is the 
library/edit_user.html template {{=grid}}  
jQuery("#no_table_region_id").change(function(){ region_id = $(this).val(); 
branch_id = jQuery('#no_table_branch_id').val(); ajax("{{=URL('library', 
'branches')}}" + '?region_id=' + region_id, [], 'no_table_branch_id'); 
jQuery('#no_table_branch_id').val(branch_id); # this does not execute }); 
jQuery(document).ready(function(){ // todo: solve the unsettable branch_id 
jQuery("#no_table_region_id").change(); });  

controller:

def branches(): if request.vars.region_id: branches = 
db(db.branch.region_id==request.vars.region_id).select(db.branch.ALL) ops1 
= [''] ops = ops1 + [f"{i[
'branch_name']}" for i in branches] else: ops = '' return ops 


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/0d311ce4-0902-4038-9f71-f17367d3f2bfn%40googlegroups.com.