I want make very simple thing. When user load page fist time variable x 
must be 0. After ajax action variable x must be equal 1. And important 
moment, that variable in must be returned in JavaScript function.
среда, 8 августа 2018 г., 18:03:23 UTC+3 пользователь Anthony написал:
>
> On Saturday, August 4, 2018 at 6:03:59 AM UTC-4, Константин Комков wrote:
>>
>> 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');
>>
>
> ':eval' is only relevant if the controller returns a string of Javascript 
> code, which your controller actions do not appear to be doing.
>  
>
>>     $('#code').css('visibility','visible');
>>     x = {{=ajaxAnswer}};
>>
>
> Note, the value of x in the line above will not be updated dynamically 
> based on the value of ajaxAnswer set on the server. Rather, this value is 
> set once on the server when the original page containing this Javascript 
> code is first served.
>
> You'll need to explain more clearly what you are really trying to do.
>
> Anthony
>

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