content-disposition on ajax requests is not allowed, therefore browser refuse to show the usual "download as file" dialog, plain and simple :D
You need to come up with an alternative plan (such as, opening a new window pointing to the url, open a hidden iframe, using 3rd party libraries that do the previous, etc) On Tuesday, March 18, 2014 9:59:40 PM UTC+1, Richard wrote: > > Hello, > > I want to call 2 functions that return a file to be upload/download into > client computer... I have been able to make the first call page to upload > file correctly, but I can't figure out how to make upload both files, I > thought I could solve the issue with ajax call, no lock. > > # controller > > def form_func_that_call_my_download_funcs(): > ... > if form.process().accpet: > ... > redirect(URL(c='label', f='download_func1', extension=False, > vars=dict(var1=var1, **other_vars_dict)), > client_side=True) # This work for one file as it should... > ... > > > def shell_func(): > return dict(a='') > > > # view > # shell_func() > <div id="batch_div"> > {{=LOAD('lotns', 'other_func_that_just_return_so_var_input', > extension='load', ajax=True, target='batch_div')}} > <!-- On submit of this view form_func_that_call_my_download_funcs() is > loaded below with web2py_component() --> > </div> > > <div id="form_func_that_call_my_download_funcs_div"> > <!-- form_func_that_call_my_download_funcs() loaded here with > web2py_component() --> > </div> > > > I try to change form_func_that_call_my_download_funcs() like this : > > def form_func_that_call_my_download_funcs(): > ... > if form.process().accpet: > ... > response.js = "$.get(url=' > http://127.0.0.1:8000/sgddms/label/download_func1?var1=2676&var1=2673&var1=2678') > ;" > response.js += "$.get(url=' > http://127.0.0.1:8000/sgddms/label/download_func2?var1=2676&var1=2673&var1=2678');" > > # I see the call passing in chrome dev tool both the files are not > download??? Try with $.post() too... > ... > > > # Here what look my download function, both are the same so I just show > the important thing in one of them... > def download_func1(): > ... > final = StringIO(final_wordml) > response.headers['Content-Type'] = 'xml' > response.headers['Content-Disposition'] = \ > 'attachment;filename=filename123_%s.xml;' % > request.now.strftime('%Y-%m-%d_%H-%M-%S-%f') > response.write(final.getvalue(), escape=False) > raise HTTP(200, str(final.getvalue()), **response.headers) > > > Thanks for any pointer! > > Richard > -- 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.