Does not return any error of an AJAX function

0

Return% empty% when I use this code (I got it on the internet):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script><scriptsrc="http://malsup.github.com/jquery.form.js"></script>
<script>
$(document).ready(function() 
{   
$(".busca").keyup(function() 
{
    var busca = jQuery(".busca").val();
    if(busca.length >= 1) 
    {

        jQuery.ajax(
        {
            type: "POST",
            url: "resultado.php",
            dataType: "html",
            data: "busca=" + busca,

            success: function(response)
            {
                jQuery("#retorno").html(response);
            },
            error: function(request, status, erro)
            {
                alert("Problema ocorrido: " + status + "\nDescição: " + erro);
                alert("Informações da requisição: \n" + request.getAllResponseHeaders());
            }
        });
    }
});
});
</script>

    
asked by anonymous 23.02.2017 / 14:53

1 answer

0

I made several simulations using the very code you posted (with a small change of instead of displaying an alert ), the message would appear in the div #retorno itself) , and the only situation in which this occurred was when I accessed the file directly through the file:

    
23.02.2017 / 20:34