unable to call ajax url from external javascript.

707 views
Skip to first unread message

Pradeesh

unread,
Feb 20, 2012, 10:08:42 AM2/20/12
to web2py-users
I am new to web2py.
form my view i am able to call web2py ajax as "
ajax("{{=URL(r=request,c='control2',f='function1')}}"['name'],'target');
". But the same command is not working from an external javascript.
How can i call a function (in another control file) using ajax from an
external JavaScript.

Anthony

unread,
Feb 20, 2012, 10:55:21 AM2/20/12
to web...@googlegroups.com
The ajax() function is in web2py.js. When you call it from an external js file, has web2py.js already been loaded in the page?

Anthony 

Alan Etkin

unread,
Feb 20, 2012, 3:01:39 PM2/20/12
to web2py-users
Maybe wrapping the code in jQuery(document).ready() the execution is
delayed enough time for the web2py functions to be read.
Message has been deleted

Vineet

unread,
Feb 20, 2012, 11:16:04 PM2/20/12
to web2py-users
In your statement --
ajax("{{=URL(r=request,c='control2',f='function1')}}"['name'],'target');

comma is missing after URL and before ['name'].
Check whether it is a typo or otherwise.

Secondly, double check whether the external js file is included in the
header section of layout.html

-- Vineet
Reply all
Reply to author
Forward
0 new messages