I run a query with ajax on a php page, the problem is that even asking to return data, the ajax 'date' does not return anything, I give an alert on the 'date' and it returns me a blank alert, JS below:
$(function(){
$(".logando").click(function(event){
event.preventDefault();
if($("#email").val() == "" || $("#senha").val() == "") {
$(".obrigatorio").slideDown(500).css("display","block");
}
else {
var emailUsuario = $("#email").val();
var senhaUsuario = $("#senha").val();
$.ajax({
type: "POST",
url: "../../controller/Logar_Cadastrar.inc.php",
data: {email: emailUsuario, senha: senhaUsuario},
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function() {
$(".obrigatorio").slideDown(100).html("Carregando");
},
success: function(data) {
alert(data);
}
})
}
})
})
Login block code HTML page:
<form action="../../controller/Logar_Cadastrar.inc.php" method="post">
<input type="text" name="email" required placeholder="Digite seu e-mail..." id="email"><br>
<input type="password" name="senha" required placeholder="Digite sua senha..." id="senha"><br>
<input type="hidden" name="logar">
<input type="submit" value="Logar-se" class="logando"><br>
</form>
PHP Code:
<?php
require_once('../model/Logar_Cadastrar.class.php');
$logarCadastrar = new Logar;
//Função para logar
if(isset($_POST['logar'])):
$email = trim(strip_tags($_POST['email']));
$senha = trim(strip_tags($_POST['senha']));
$verificar = $logarCadastrar->Consulta("SELECT * FROM CS_usuarios WHERE email = ? AND senha = ?","ss","{$email}","{$senha}");
if($verificar >= 1):
// return "Encontrado";
echo "Encontrado";
else:
// return "Não encontrado";
echo "Não encontrado";
endif;
endif;