Good morning!
I have the following code:
<?php
$titulo = "Site";
?>
<html>
<head>
<title><?php echo $titulo; ?></title>
<link rel="shortcut icon" href="_imgs/favicon.ico">
<script type="text/javascript" src="_scripts/_js/jquery-2.1.4.min.js"></script>
<link type="text/css" rel="stylesheet" href="_css/estilo.css" />
</head>
<body>
<div class="corpo">
<div class="cabecalho">
<h2 id="tituloCabecalho"> Bem Vindo ao Portal do Cliente <a href="index.php"><?php echo $titulo; ?></a> </h2>
</div>
<div id="formLogin" class="login">
<form action="" method="post" >
<label>Entrar</label> <br /> <br />
<input type="email" name="email" id="email" class="email" placeholder="E-mail" class="camposForm" required /> <br /> <br />
<input type="password" name="senha" id="senha" class="senha" placeholder="Senha" class="camposForm" required /> <br /> <br />
<input type="checkbox" name="lembrar" id="lembrar" class="lembrar" /> <label id="lembrarLabel">Lembrar-me</label> <br /> <br />
<div class="entrarRecuperar">
<div class="entrarDiv"><button id="entrar" class="btnEntrar">Entrar</button></div>
<div class="recuperarDiv"><a href="recuperaSenha.php">Esqueceu sua senha?</a></div>
</div>
<div class="clear"></div>
<div id="erroLogin"></div>
</form>
</div><br>
<div class="cadastro">Registro</div>
</div>
</body>
</html>
<script>
$('#entrar').click(function () {
email = $('#email').val();
senha = $('#senha').val();
if (email=="") {
alert("Preencha E-mail");
return false;
}
if (senha=="") {
alert("Preencha Senha");
return false;
}
$.ajax({
type: "POST",
url: "_requeridos/sessaoLogin.php",
data: {email: email, senha: senha},
dataType: 'json'
}).done(function(resposta){
alert();
if (resposta == "ERRO") {
$("#erroLogin").html("Erro de Login");
} else {
window.location="oi.html";
}
});
return false;
});
</script>
The js $.ajax({
above is not able to find the form field values.
What's wrong with this code?
Actually not even getting into Ajax.