Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.done is not a function

I've another problem. I get an error in FireFox and I don't know what my fault is. I always did it like this way and I never got an error. I already check lower/uppercase mistakes but I can't find anything.

Thanks

$.ajax({type: "POST", url: "ajax/check_username.php", data: {username: username}}).done is not a function

<script type="text/javascript">
$(document).ready(function(){
    $("#username").keyup(function(){
        var username = $("#username").val();
        $(".usernameFeedback").fadeIn("fast");

        $.ajax({
            type: "POST",
            url: "ajax/check_username.php",
            data: { username: username }
        }).done(function( msg ) {
            $("#loadingImage").hide();
            if(msg.status != "error")
                {
                    if(msg.available == "yes")
                    {
                        $(".usernameFeedback span").text(msg.message);
                        $(".usernameFeedback span").removeClass("notok");
                        $(".usernameFeedback span").addClass("ok");
                    }
                    else
                    {
                        $(".usernameFeedback span").text(msg.message);
                        $(".usernameFeedback span").addClass("notok");
                    }
                }
        });
        return(false);
    })
});
</script>
like image 772
Niels Avatar asked May 02 '12 15:05

Niels


1 Answers

Probably your jQuery version is too old. You need at least jQuery 1.5 for jqXHR objects to implement the Promise interface you are using.

If you cannot upgrade for some reason, simply use the success option:

$.ajax({
    type: "POST",
    url: "ajax/check_username.php",
    data: { username: username },
    success: function(msg) {

    }
});
like image 188
ThiefMaster Avatar answered Oct 14 '22 09:10

ThiefMaster