Are there somebody?

суббота, 4 августа 2018 г., 13:03:59 UTC+3 пользователь Константин Комков 
написал:
>
> Hello!
>
> Can you take advice, how can I understan than answer from server was 
> received in JS?
> Controller:
> def swed():
>     ajaxAnswer = 0
>     return dict(ajaxAnswer=ajaxAnswer)
> def VcodeToDbAndMail():
>     ajaxAnswer = 1
>     return dict(ajaxAnswer=ajaxAnswer)
> JS
> <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>
> In both cases x = 0. I think it because console.log has started before 
> ajax was ended.
> Also, if i don't return ajaxAnswer in action "swed", I have error: name 
> 'ajaxAnswer' is not defined. 
> But in example: Chapter 11 - Eval target, if we using ':eval' I don't see 
> that action "one" in controller return something.
>
> Thank you!
>
>

-- 
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.

Reply via email to