用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - javascript代码库

聊天室JSON

2015-06-17 作者: 莫名其妙举报

[javascript]代码库

   <script type="text/javascript" language="javascript">

        $(function () {
            //同步问题信息
            $("#comemnt_list").ready(function () {

                startRequest();
                setInterval("startRequest()", 5000);
            });
        });
        //获取聊天信息
        function startRequest() {
            var STDBXID = getArgs("AutoID");
            $.ajax({
                type: "POST",
                url: "STDBZMainTalkShow.ashx",
                dateType: "json",
                data: { STDBXID: STDBXID },
                success: function (returnedData) {
                    if (returnedData) {
                        var result = eval('(' + returnedData + ')');
                        var Total = result.Total;
                        $("#comemnt_list").html(Total);
                    } else {
                        $("#comemnt_list").html("获取聊天信息出错");
                    }
                }
            });
        }
        //输入聊天信息
        function TalkInsert() {
            STDBXID = getArgs("AutoID");
            var Message = $.trim($("#comment_content").val());
            var User = $.trim($("#ContentPlaceHolder_UserID").val());
            var ENTID = $.trim($("#ContentPlaceHolder_ENTID").val());
            if (Message == "" || Message == null) {
                alert("内容不能为空")
            }
            else {
                $.ajax({
                    type: "POST",
                    url: "STDBZMainTalkInsert.ashx",
                    dateType: "json",
                    data: { Message: Message, User: User, STDBXID: STDBXID, ENTID: ENTID },
                    success: function (returnedData) {
                        if (returnedData) {
                            $("#comment_content").val('');
                            startRequest();
                        } else {
                            $("#comment_content").val('系统异常');
                        }
                    }
                });
            }

        }
        //获取query string
        function getArgs(strParame) {
            var args = new Object();
            var query = location.search.substring(1); // Get query string
            var pairs = query.split("&"); // Break at ampersand
            for (var i = 0; i < pairs.length; i++) {
                var pos = pairs[i].indexOf('='); // Look for "name=value"
                if (pos == -1) continue; // If not found, skip
                var argname = pairs[i].substring(0, pos); // Extract the name
                var value = pairs[i].substring(pos + 1); // Extract the value
                value = decodeURIComponent(value); // Decode it, if needed
                args[argname] = value; // Store as a property
            }
            return args[strParame]; // Return the object
        }
    </script>


=================================================show.ashx
<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;
using System.Data;
using System.Configuration;
using entsut.DAL;
public class Handler : IHttpHandler
{


    public void ProcessRequest(HttpContext context)
    {
        string json = "";
        string STDBXID = context.Request["STDBXID"].ToString();


        try
        {
            DataSet ds = Common.NoPager2("Std_BZQqustions", "10", "ID,QuestionDes,createTime,createUser,createUser_entID", "createTime Desc", "STDBXID='" + STDBXID + "' and Valided=1");

            DataTable dt = ds.Tables[0];
            int i = dt.Rows.Count;
            string[] talk = new string[i];
            string Total = null;
            for (int j = 0; j <= i - 1; j++)
            {
                talk[j] = "<li class=\"comment_list\" style=\"font-size: 12px;\"><span class=\"creator\">" + dt.Rows[j]["createUser"] + "<a class=\"talktime\">(" + dt.Rows[j]["createTime"] + ")</a></span>:<p class=\"talk\">" + dt.Rows[j]["QuestionDes"] + "</p></li>";
                Total = Total + talk[j];
            }
            json = "{'Total':'" + Total + "'}";
            context.Response.Write(json);
        }
        catch
        {
            context.Response.Write(json);
        }



    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}
===================================insert
<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;
using System.Data;
using System.Configuration;
using entsut.DAL;
using entsut.Core;
using System.Text.RegularExpressions;
public class Handler : IHttpHandler
{


    public void ProcessRequest(HttpContext context)
    {
        string json = "";
        string STDBXID = context.Request["STDBXID"].ToString();
        string Message = context.Request["Message"].ToString();
        string UserID = context.Request["User"].ToString();
        string ENTID = context.Request["ENTID"].ToString();
        try
        {
                string Notice = Common.Insert2("Std_BZQqustions", "QuestionDes,createTime,createUser,createUser_entID,Valided,STDBXID", "'" + Message + "','" + DateTime.Now + "','" + UserID + "','" + ENTID + "',1,'" + STDBXID + "'");
                json = "{'Notice':'" + Notice + "'}";
                context.Response.Write(json);

        }
        catch
        {
            context.Response.Write(json);
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}



网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...