Hi guys, i have a problme with a form that login the user in my app. Oviusly the list of users is saved on my database on my webserver.
This is the code:
HTML
[CODE]
<div data-role="page" id='login'>
<!--<div data-role="header">
<h1>Page Title</h1>
</div><!-- /header -->
<div data-role="content" >
<div class="login_box">
<form action="#" method="get" class="form_login">
<label>login</label>
<div class="error_box"></div>
<input type="text" id="user" name="user">
<input type="password" id="password" name="password">
<input type="submit" id="submit_login" value="Entra">
</form>
</div>
</div><!-- /content -->
<!--<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
[/CODE]
Javascript
[CODE]
$(document).ready(function(){
/****************************************Login**************************************/
$(".form_login").submit(function(){
var user = $("#user").val();
var password = $("#password").val();
if(user == "" || password == ""){ $(".error_box").html("<p> Username o Password mancanti! </p>") }
else{
$.ajax({
type: "GET",
url: "URL TO PHP FILE ON MY SERVER",
data: "login&user="+user+"&password="+password,
success:function(response){
if(response == "0"){$.mobile.changePage("#home", { transition: "slide"}) }
if(response == "1"){ $(".error_box").html("<p> Username o Password errate! </p>") }
}
}); return false;
} return false;
})
})
[/CODE]
With this codes i obtain the error if i leave the inputs empty but if i insert user and pass nothing happens.
Why? How i can use go button on the ipad keyboard and tod an ajax request without refreshing of the page?
Thank for help!