What's wrong with my Ajax?

0

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));
    
asked by anonymous 24.03.2015 / 16:58

1 answer

4

You are using "dateType", the correct one is "dataType".

    
25.03.2015 / 18:39