ajax局部刷新指定的DIV失败了!快来帮帮我呀····

大神帮我看看这段评论代码,怎么局部刷新DIV?div的ID是:comment-list
修改很多次,每次评论后 弹出提示框说评论成功,必须要手动刷新页面才显示新的评论,我该怎么做呢?可以详细点吗?

//评论
                comment.find('.dingcai').click(function(){
                    var self = $(this).parent(),
                        id = self.data('id'),
                        box = self.parents('.main-list').find('.joke-list-comment');
                    if(flag == -1){
                        App.request({
                            url : '/xiaohua/getreview',
                            data : {id : id,p : 1},
                            success: function(result){
                                var re = result || {};
                                if(re.err){
                                    var obj = {list : re.msg || {}},
                                        html = null,
                                        mainList = self.parents('.main-list'),
                                        godreplyID = mainList.find('.godreply').data('id');
                                    obj.islogin = _this.isLogin();
                                    obj.godreplyID = godreplyID || 0;
                                    html = template.compile(reply)(obj);
                                    mainList.append(html);
                                    mainList.find('.joke-list-comment .comment_packUp').on('click',function(){
                                        $(this).parents('.joke-list-comment').hide();
                                        flag = 1;
                                    });
                                    mainList.find('.loginClickHref').on('click',function(){
                                        _this.loginDialog();
                                    });
                                    //评论
                                    mainList.find('.comment-submit').on('click',function(){
                                        var form = $(this).parent(),
                                            data = form.serializeObject();
                                        data.id = id;
                                        if(!data.content || data.content.length > 140){
                                            App.alert('回复内容不能为空!');
                                            return;
                                        };
                                        App.request({
                                            url : '/ajax/review',
                                            data : data,
                                            success : function(result){
                                                var re = result || {};
                                                if(re.err){
                                                    form.find('.comment-input-text').val('');
                                                    App.alert('评论成功!');
                                                    return;
                                                    var obj = re.msg[0],
                                                        ul = mainList.find('.comment-list'),
                                                        li = ul.find('li'),
                                                        is_reply = li.eq(0).hasClass('nocomment'),
                                                        index = is_reply ? 1 : li.size() + 1;
                                                    var _html = '<li>\
                                                                    <div class="comment-content">\
                                                                        <a class="user_id" href="/user/'+obj.user_info.id+'" data-id="'+obj.user_info.id+'"> <img src="'+obj.user_info.avatar+'" alt="'+obj.user_info.username+'" /><i></i> </a>\
                                                                        <p class="comment-username"><a href="/user/'+obj.user_info.id+'">'+obj.user_info.username+'</a></p>\
                                                                        <p class="p-content">'+obj.content+'</p>\
                                                                    </div>\
                                                                    <div class="comment-ding">\
                                                                        <span>'+index+'楼</span>\
                                                                        <a href="javascript:void(0);" class="comment-ding-icon" data-id="'+obj.id+'">0</a>\
                                                                        <a class="comment-reply" href="javascript:void(0);">回复</a>\
                                                                    </div>\
                                                                </li>';
                                                        if(is_reply){
                                                            ul.html(_html);
                                                        }else{
                                                            if(li.size() == 5){
                                                                li.eq(-1).remove();
                                                                ul.prepend(_html);
                                                                var index = 6;
                                                                for(var i=1; i<=li.size(); i++){
                                                                    ul.find('.comment-ding span').eq(i-1).text((index = index-1)+'楼');
                                                                };
                                                                return;
                                                            };
                                                            ul.prepend(_html);
                                                        };
                                                }else{
                                                    App.alert(re.msg);
                                                };
                                            }
                                        });
                                    });
                                    //点赞
                                    mainList.on('click','.comment-ding-icon',function(){
                                        var self = $(this),
                                            id = self.data('id');
                                        _this.commentDing(self,id);
                                    });
                                    //回复
                                    mainList.on('click','.comment-reply',function(){
                                        if(!_this.isLogin()){
                                            _this.loginDialog();
                                            return;
                                        };
                                        _this.reply($(this));
                                    });
                                }else{
                                    //info.show().html(re.msg);
                                };
                                flag = 0;
                            }
                        });
                    };
                    if(flag == 0){
                        box.hide();
                        flag = 1;
                    }else if(flag = 1){
                        box.show();
                        flag = 0;
                    };
                });
阅读 3.4k
3 个回答

来来来,解释一下return
clipboard.png

为什么评论成功过后有个return啊

432客户管理管理

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进