It was my mistake. When we using ajax we can see ticket press F12 -> 
network.

среда, 1 августа 2018 г., 15:56:13 UTC+3 пользователь Константин Комков 
написал:
>
> 1. Can I send two or more variables in function ajax()?
>
> In the book I saw parameters of ajax function:
> ajax(url, [name1, name2, ...], target)
> As I understand name1 and name2 it's variables.
>
> 2. There is way to send only one variable (email), if checkbox cheked, 
> from my form (view below)?
>
> 3. If I haven't opportunity don't send one variable - I send two 
> variables. And if checkbox cheked, I get error "An error occured, please 
> reload the page".
> Model:
> db_app = DAL("sqlite://storage.sqlite")
> db_app.define_table('post',Field('email', 'text', requires = 
> [IS_NOT_EMPTY(),IS_EMAIL()]),Field('country', 'text',requires = 
> IS_NOT_EMPTY()))
> Controller:
> def swed():
>     return dict()
>
> def new_post():
>     form = SQLFORM(db_app.post)
>     if form.accepts(request, formname=None):
>         return XML("<div>On Your email - <b>"+request.vars.email+"</b> was 
> send validation code.</div>")
>     elif form.errors:
>         return TABLE(*[TR(k, v) for k, v in form.errors.items()])
> View:
> <form id="myform">
> <input type="checkbox" id="country" name="country" value="Россия" 
> class="form-check-input left" checked="checked" />
> <label for="country" style="font-weight: 400;" class="form-check-label 
> left">My country is Russia.</label>
> <div id="target" class="form-group row"></div>
> <input name="email" id="email" type="email" class="form-control" 
> placeholder="email" />
> <input type="submit" id="btnCode" name="send_message" value="Get code" 
> class="btn btn-primary" style="width: 100%;" />
> <input type="text" class="form-control" name="code" id="code" 
> placeholder="Validation code" disabled="disabled" />
> </form>
> <script>
> jQuery('#myform').submit(function() {
>   ajax('{{=URL("new_post")}}',
>        ['email', 'country'], 'target');
>   return false;
> });
> </script>
> Error in flash: An error occured, please reload the page
>
>
>
>

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