[Hỏi đáp] Code trả lời bài viết không chuyển trang bị lỗi, chỉ hiện comment khi f5

  Bài viết hay nhất1
Mình có đoạn js sau:
Code:
$(function () {
    $('#quick_reply input[name="post"]').click(function(a){
    a.preventDefault();
    var g = $("#text_editor_textarea").sceditor('instance').val();
    var href = $('a[href*="mode=reply"]').attr("href");
    var value = $("#text_editor_textarea").sceditor("instance").val().replace(/\s/g, '').length;
    if(10 < value) {
    $('<div class="lreply"><br /><img src="http://i35.servimg.com/u/f35/15/64/85/86/ajax-l10.gif"><br><b>Đang cập nhật bình luận của bạn...</b></div>').appendTo(".frm-buttons");
    $.post(href, {
       "message": g,
       "auth[]": $("#quick_reply input[name='auth[]']:last").val(),
       "lt": $("#quick_reply input[name='lt']").val(),
       "attach_sig": "1",
       "post": "Send"
         }, function (t) {
            if (t.indexOf("Flood") != -1 && $("html").attr("xml:lang") == "vi") {
               alert("THÔNG BÁO!!!\nNghi vấn spam, tài khoản của bạn đang được xem xét và có thể bị khóa nếu vẫn comment liên tục trong thời gian ngắn như vậy. Vui lòng comment chậm lại\n(Chờ 60 giây sau để tiếp tục comment.)");
               $(".lreply").remove();
            } else if (t.indexOf("Flood") != -1 && $("html").attr("xml:lang") != "vi") {
               alert("Error!\nYou must wait 60 second before replying");
               $(".lreply").remove();
            }
            if (t.indexOf("A new") != -1 && $("html").attr("xml:lang") == "vi") {
               alert("Lỗi!\nĐã có người gửi bài trước bạn.\nBạn phải F5 lại trang để tiếp tục.\nChú ý : Bạn nên copy lại tin nhắn trước khi F5 ");
               $(".lreply").remove();
            } else if (t.indexOf("A new") != -1 && $("html").attr("xml:lang") != "vi") {
               alert("Error!\nSomeone had replied before your post\nYou must refresh the page to continue.\nNotice : You should save or copy your message if you don't want it gone");
               $(".lreply").remove();
            } else {
               var f = $(t).find(".message a:first").attr('href');
               f = f.match(/\/(t\d+(p\d+)?)-.+/)[1];
               location.href = location.href.replace(/(.+\/)(t\d+(p\d+)?)(-.+)/, "$1" + f + "$4");
               $.get(location.href, function (z) {
                  $("#quick_reply input[name='auth[]']:last").val($(z).find("#quick_reply input[name='auth[]']:last").val());
                  $("#quick_reply input[name='lt']").val($(z).find("#quick_reply input[name='lt']").val());
                  $(z).find(".post:last").hide().insertAfter(".post:last").slideDown(400);
               });
               $("#text_editor_textarea").sceditor('instance').val("");
               $(".lreply").remove();
            }
         });
      } else {
         if ($("html").attr("xml:lang") == "vi") {
            alert("Xin lỗi\nNội dung quá ngắn không thể gửi bài !\nBạn cần nhập thêm " + (10 - value) + " ký tự nữa.");
         } else {
            alert("Sorry\nThe content is too short to send as post !\nYou must write " + (10 - value) + " characters more.");
         }
      }
   });
});

Đoạn code này cho phép trả lời nhanh nhưng phải f5 mới hiện comment. Còn nhập text vào rồi click "Send" thì nó load mãi không chịu hiện comment. Mình chờ mãi mới thấy box Hỏi đáp hoạt động để gửi thắc mắc. Mong sẽ sớm nhận được sự giúp đỡ :)

P/s: Tks vì đã ghé thăm topic :)
  Bài viết hay nhất2
Demo + Nick test!
  Bài viết hay nhất3
Nick: Zzbaivong
Pass: baivong123
http://www.congdongotakuviet.com/t2177-tuyen-cong-tac-vien-dang-tin-quang-cao (Baivong có cmt để test thì vào topic này)
  Bài viết hay nhất4

anhdaodaica1 wrote:Nick: Zzbaivong
Pass: baivong123
http://www.congdongotakuviet.com/t2177-tuyen-cong-tac-vien-dang-tin-quang-cao (Baivong có cmt để test thì vào topic này)

Xin lỗi, chỉ có Người quản trị được quyền đọc bài gửi trong diễn đàn này.
Cho cái demo mà ko cho xem thì chịu :v
  Bài viết hay nhất5
Được chưa BaiVong?
  Bài viết hay nhất6
Lúc nãy bị rớt mạng, giờ mới vào lại được, mất code luôn phải viết lại, mà bạn bỏ code cũ vào thì mình không kiểm tra được, nên lỗi tự chịu.

Code:
$(function() {
    $('#quick_reply input[name="post"]').click(function(a) {
        a.preventDefault();
        var g = $("#text_editor_textarea").sceditor('instance').val();
        var href = $('a[href*="mode=reply"]').attr("href");
        var value = $("#text_editor_textarea").sceditor("instance").val().replace(/\s/g, '').length;
        if (10 < value) {
            $('<div class="lreply"><br /><img src="http://i35.servimg.com/u/f35/15/64/85/86/ajax-l10.gif"><br><b>Đang cập nhật bình luận của bạn...</b></div>').appendTo(".frm-buttons");
            $.post(href, {
                "message": g,
                "auth[]": $("#quick_reply input[name='auth[]']:last").val(),
                "lt": $("#quick_reply input[name='lt']").val(),
                "attach_sig": "1",
                "post": "Send"
            }, function(t) {
                var $new = $(t).find('.message a[href^="/viewtopic"]');
                if ($new.length) {
                    $.get($new.attr("href"), function(z) {
                        $("#quick_reply input[name='auth[]']:last").val($(z).find("#quick_reply input[name='auth[]']:last").val());
                        $("#quick_reply input[name='lt']").val($(z).find("#quick_reply input[name='lt']").val());
                        $(z).find(".post:last").hide().insertAfter(".post:last").slideDown(400)
                    });
                    $("#text_editor_textarea").sceditor('instance').val("");
                    $(".lreply").remove();
                } else {
                    if (t.indexOf("Flood") != -1 && _userdata["user_lang"] === "vi") {
                        alert("THÔNG BÁO!!!\nNghi vấn spam, tài khoản của bạn đang được xem xét và có thể bị khóa nếu vẫn comment liên tục trong thời gian ngắn như vậy. Vui lòng comment chậm lại\n(Chờ 60 giây sau để tiếp tục comment.)");
                        $(".lreply").remove();
                    } else if (t.indexOf("Flood") != -1 && _userdata["user_lang"] === "vi") {
                        alert("Error!\nYou must wait 60 second before replying");
                        $(".lreply").remove();
                    } else if (t.indexOf("A new") != -1 && _userdata["user_lang"] === "vi") {
                        alert("Lỗi!\nĐã có người gửi bài trước bạn.\nBạn phải F5 lại trang để tiếp tục.\nChú ý : Bạn nên copy lại tin nhắn trước khi F5 ");
                        $(".lreply").remove();
                    } else if (t.indexOf("A new") != -1 && _userdata["user_lang"] === "vi") {
                        alert("Error!\nSomeone had replied before your post\nYou must refresh the page to continue.\nNotice : You should save or copy your message if you don't want it gone");
                        $(".lreply").remove();
                    }
                }
            });
        } else {
            if ($("html").attr("xml:lang") == "vi") {
                alert("Xin lỗi\nNội dung quá ngắn không thể gửi bài !\nBạn cần nhập thêm " + (10 - value) + " ký tự nữa.")
            } else {
                alert("Sorry\nThe content is too short to send as post !\nYou must write " + (10 - value) + " characters more.")
            }
        }
    })
});
  Bài viết hay nhất7
Chuẩn hơn cả đoạn code cũ, tk BaiVong nhiều :D
  Bài viết hay nhất8
You cannot reply to topics in this forum