Javascript is asynchronous -- the document.write() line will be executed before the ajax call has completed. Try putting the document.write() in the returned Javascript itself.
On Wednesday, January 15, 2014 11:09:04 AM UTC-5, jonas wrote: > > Hi > > I have a controller that is supposed to return a list to a js function > (for testing purposes): > > def test(): > > print "called2" > > data=[3, 6, 2, 7, 5, 2, 0, 3, 8, 9, 2, 5, 9, 3, 6, 3, 6, 2, 7, 5, 2, > 1, 3, 8, 9, 2, 5, 9, 2, 7] > > return 'var data=%s;' % data > > I am calling this with an ajax function: > > <script> > ajax('{{=URL('test')}}',[],':eval'); > document.write(data); > </script> > > but is seems that the data is not present in the script. > > what went wrong? > -- 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/groups/opt_out.