Hi,
I'm new to web2py. Can some1 tell me how to debug javascript
code in web2py? I've written the following code and am not able to
debug it...can some1 help me out plz...
in controllers/identity.py
def getcities():
citystr = request.vars.values()[0]
output = "<h1>Nizamabad</h1>"
if int(citystr) == 1:
output = "<h1>Hyderabad</h1>"
elif int(citystr) == 2:
output = "<h1>Chennai</h1>"
elif int(citystr) == 3:
output = "<h1>Pune</h1>"
return output
def index():
form=FORM(TABLE(
TR("State:",\
SELECT("Andhra Pradesh","Delhi","Tamil
Nadu",_name="state", _id="States",default="Andhra
Pradesh",_onchange="ajax('{{=URL(r=request,f='getcities')}}',
['States'],'handle')",requires=[IS_NOT_EMPTY()])),\
TR(DIV(_id="handle"))))
return dict(form=form)
in identity/index.html
{{extend 'layout.html'}}
<script type="text/javascript"><!--
function myajax(u,s,t) {
var query="";
for(i=0; i<s.length; i++) { if(i>0) query=query+"&";
query=query+encodeURIComponent(s[i])+"="+encodeURIComponent
(document.getElementById(s[i]).value);
}
$.ajax({type: "POST", url: u, data: query, success: function(msg)
{ document.getElementById(t).value=msg; } });
}
//--></script>
<div = "content">
<div id="flash">{{=response.flash}}</div>
<h2>Register</h2>
{{=form}}
</div>
I'm not able to pick where the connection is lost. Is my ajax function
working and communicating with getcities method or is it the wrong way
to write the handle function?
Its really a urgent thing for me. Please help me out. Thanks in
advance...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---