TypeError:$ .post(...).success不是函数

Pet*_*ete -1 javascript jquery

有人可以帮助我使用下面的代码..在Firefox开发人员工具中我收到错误信息:: TypeError:$ .post(...).success is not a function

所有变量都从表单页面提交.

任何意见和建议将不胜感激......

谢谢

$(document).ready(function(){

    $('#post-comment-btn').click(function(){

        var _comment = $('#comment-post-text').val();
        var _userId = $('#userId').val();
        var _userName = $('#userName').val();

        if(_comment.length > 0 && _userId != null) {

            $.post("ajax/comment_insert.php",

                {
                    task : "comment_insert",
                    userId : _userId,
                    comment: _comment,


                }
                ).success(
                    function(data)
                {
                    console.log("ResponseText:" + data);
                }

                );


            console.log(_comment + " Username: " + _userName + " User Id: " + _userId);

        } else {

            console.log("The text area is empty..");

        }

        $('#comment-post-text').val("");


    });

});
Run Code Online (Sandbox Code Playgroud)

ade*_*neo 7

有没有$.post().success方法了,该函数返回一个承诺,可以与使用done,fail,always,then等,但不success

$.post("ajax/comment_insert.php", {
    task    : "comment_insert",
    userId  : _userId,
    comment : _comment,
}).done(function(data) {
    console.log("ResponseText:" + data);
});
Run Code Online (Sandbox Code Playgroud)

jQuery中所有ajax方法的文档现在清楚地说明了这一点

jqXHR.success(),jqXHR.error()jqXHR.complete()回调方法也会被删除的jQuery 3.0.您可以使用jqXHR.done(), jqXHR.fail()jqXHR.always()来代替.