简体   繁体   中英

.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>

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) {

    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM