之前用过ajax,但是这次ajax没有传参数,我已经尝试了一些解决方案,但是都解决不了。
jQuery
$('.entrar').click(function(){
event.preventDefault();
if (check_login()){
var dataLogin;
var manter_ligado;
if ($('#mantem_login').is(':checked'))
{
manter_ligado = "1";
} else {
manter_ligado = "0";
}
dataLogin = 'mail=' + $('#login_mail').val() + '&pass=' + $('#login_password').val() + '&on=' + manter_ligado;
$.ajax({
url: 'modules/login.php',
type: 'POST',
//data: dataLogin,
data : ({
mail : $('#login_mail').val(),
pass : $('#login_password').val(),
on : manter_ligado
}),
success: function(data) {
alert('Login efectuado com sucesso.');
console.log(data);
},
error: function(xhr, textStatus, errorThrown) {
alert('Login nao entrou');
console.log(xhr.statusText);
console.log(textStatus);
console.log(error);
}
});
return false;
}
})
这是 HTML
<span class="title">Entrar na sua conta</span>
<input name="login_mail" placeholder=" e-mail" id="login_mail" type="email" class="email text_box"/>
<input name="login_password" placeholder="password" id="login_password" type="password" class="password text_box" />
<span>Perdeu a password?</span>
<div class="mantem_login">
<input name="mantem_login" id="mantem_login" type="checkbox" class="mantem_login" />
<label for="mantem_login"><span class="mantem_login">Manter-me conectado</span></label>
</div>
<input type="submit" name="entrar" class="submit_button entrar" id="entrar" value="" />
</div>
</form>
我该怎么做才能使参数到达 url?