My code has no return and I can not figure out why.
index.php
<form id="login" method="POST">
<input type="text" name="username" placeholder="Usuário ou email" />
<input type="text" name="password" placeholder="Senha" />
<button onclick="enviar()" type="submit">Entrar</button>
</form>
<script type="text/javascript">
function enviar() {
var formula = $('#login').serialize();
$.ajax({
type: 'POST',
dateType: 'json',
data: formula,
url: 'http://localhost/teste/enviar.php',
success: function(data) {
if (data == 1) {
alert("OK");
window.location = "";
}
if(data == 0) {
alert("Nada OK");
window.location = "";
}
},
error: function(error) {
console.log(error.responseText);
}
})
return false;
}
</script>
<script type="text/javascript" src="js/jquery-2.1.3.js"></script>
Send.php
<?php
$resposta = 1;
echo (json_encode($resposta));