ajax Post请求方法

;
var common_index_ops = {
    init:function(){
        this.eventBind();
    },
    eventBind:function(){
        $(".save").click(function(){
            var btn_target = $(this);
            if(btn_target.hasClass("disabled")){
                alert("正在处理,请不要重复提交~");
                return;
            }
            var nickname_target = $(".wrap_account_set input[name=nickname]");
            var nickname = nickname_target.val();
            if(nickname.length < 1){
                alert("请输入规范的昵称");
                return;
            }
            btn_target.addClass("disabled");
            var data  = {
              nickname:nickname
            };
            $.ajax({
                url:"",
                type:"POST",
                data:data,
                dataType:"json",
                success:function (res){
                    btn_target.removeClass("disabled");
                    if(res.code == 1){

                    };
                },
                error:function (res){
                    btn_target.removeClass("disabled");
                }
            });


        });
    },


};
$(document).ready(function(){
    common_index_ops.init();
});



 

 

posted @ 2022-09-16 18:38  X__cicada  阅读(59)  评论(0编辑  收藏  举报