login form is modal form inside index, and send login form via ajax to 
login() function, but i can not login.

def login():
    form=auth.login()
    if form.accepts(request,session=None):
        return 'logged'
    else: return 'failed'

below section is in index page view: 
  <form action=''>
    <fieldset>
        <div id='login_result'></div>
    <label>Email</label>
    <input name='email' id='email' type="text" placeholder="Email Address">
    <label>Password</label>
    <input name='password' id='password' type="password" 
placeholder="*********"><br/>    
    <button id='loginbtn' class="btn" Onclick='login();return 
false;'>Submit</button>
    </fieldset>
    </form>

<script>
    function login(){
    $.ajax({  
  type: "POST",  
        url: '{{=URL('default','login')}}',  
          data: 
'email='+$('#email').val()+'&password='+$('#password').val(),
        success : function(data){
            if (data != 'logged){
                $('#login_result').addClass('alert 
alert-error').text('Email Or password were wrong! Please try again.');
    } else {
           alert('logged');
           }
        }
});  
    
    }
</script>


i also tried auth.login_bare in login() function , but it doesnt update 
session. any idea to what should i do to correct this?

-- 

--- 
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/groups/opt_out.


Reply via email to