def swed(): ajaxAnswer = 0 return dict(ajaxAnswer=ajaxAnswer)
def VcodeToDbAndMail(): ajaxAnswer = 1 return dict(ajaxAnswer=ajaxAnswer)<script>jQuery('#myform').submit(function() { var x = 0; ajax('{{=URL("VcodeToDbAndMail")}}',['email'], ':eval'); $('#code').css('visibility','visible'); x = {{=ajaxAnswer}}; console.log(x); return false;});
</script>
Hello!Can you take advice, how can I understan than answer from server was received in JS?Controller:JSdef swed():ajaxAnswer = 0return dict(ajaxAnswer=ajaxAnswer)
def VcodeToDbAndMail():ajaxAnswer = 1return dict(ajaxAnswer=ajaxAnswer)<script>jQuery('#myform').submit(function() {var x = 0;ajax('{{=URL("VcodeToDbAndMail")}}',['email'], ':eval');
$('#code').css('visibility','visible');x = {{=ajaxAnswer}};
--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/wnyN0bjG2OE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def VcodeToDbAndMail():
return 1<script>
let x = 0
function showCode(data) {
x = parseInt(data);
$('#code').css('visibility', 'visible');
}
jQuery(function() {
jQuery('#myform').submit(function(e) {
e.preventDefault();
ajax('{{=URL("VcodeToDbAndMail")}}', ['email'], showCode);
});
});
</script>Thank you, I thought that third parametr of ajax function might be only 'target' or ':eval'.