• Online_ChatRomm


     $(document).ready(function() {
            var timeid = null;
            timeid = setInterval('counter()', 5000);
        }).keydown(function(event) {
        var key = window.event ? event.keyCode : event.which;
        if ((key.toString() == "13") && (event.ctrlKey)) {
            sendMsg();
        }
        });
        function counter() {
            $.ajax({
                url: "BaseAjaxAppliction/newmsg.ashx",
                type: "get",
                dataType: "html",
                data: "myId=<%= MyId %>&friendId=<%= FriendId %>",
                success: function(msg) {
                    if (msg != "0") {
                        $("#body").append(msg);
                    }
                }
            });
            setTimeout('scrollDiv()', 100);
        }
        function sendMsg() {
            if ($("#content").val() == "") {
                $("#error").html("<span style=\"font-color:red;\">发送消息不能为空!</span>");
                return false;
            }
            $.get("BaseAjaxAppliction/newmsg.ashx", { body: $("#content").val(), myId: "<%= MyId %>", friendId: "<%= FriendId %>" },
                    function(msg) {
                        if (msg == "1") {
                            var de = new Date();
                            $("#body").append("<ul><li>我  " + de.toLocaleString() + "</li><li>说:" + $("#content").val() + "</li></ul>");
                            $("#content").val("");
                        }
                        else {
                            $("#error").html("<span style=\"color:red;\">消息发送失败,请重发!</span>");
                            $("#content").val("");
                        }
                    });
                    setTimeout('scrollDiv()', 100);
        }
        function scrollDiv(){
            $("#bodys").scrollTop($("#body").height());
        }
  • 相关阅读:
    PHP时间戳常用转换
    redis基本指令
    P2501 [HAOI2006]数字序列
    P2679 子串
    P2759 奇怪的函数
    P6823 「EZEC-4」zrmpaul Loves Array
    P6631 [ZJOI2020] 序列
    P2887 [USACO07NOV]Sunscreen G
    P3287 [SCOI2014]方伯伯的玉米田
    拓展欧几里得算法揭秘
  • 原文地址:https://www.cnblogs.com/Andon_liu/p/1340642.html
Copyright © 2020-2023  润新知