博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
无刷新效果统计在线人数
阅读量:4545 次
发布时间:2019-06-08

本文共 1042 字,大约阅读时间需要 3 分钟。

    <script src="js/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {


            function GetUser() {

                WebApplication1.WebService1.GetCountPerson(onSuccess, onFailed);
                
            }
            function onSuccess(result) {

                $('#spcount').text(result);
            }
            function onFailed() {

                $('#spcount').text('获取失败');
            }


            setInterval(GetUser, 2000);
        
        })
    </script>


</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
      <Services>
        <asp:ServiceReference Path="~/WebService1.asmx" />
      </Services>
    </asp:ScriptManager>
    <div>
         <div>当前在线总人数:<span id="spcount"></span></div>
    </div>
    </form>

</body>

 

WebService

  [WebMethod]         public string GetCountPerson()         {             return Application["count"].ToString();          }

 

Global

 protected void Application_Start(object sender, EventArgs e)         {             Application["count"] = 0;         }

        protected void Session_Start(object sender, EventArgs e)         {             int count = Convert.ToInt32(Application["count"]);             count++;             Application["count"] = count;         }

转载于:https://www.cnblogs.com/qiqiBoKe/archive/2013/05/22/3092292.html

你可能感兴趣的文章
Mac系统配置JDK环境变量
查看>>
多项式累加
查看>>
剑指offer(18)二叉搜索树的后续遍历
查看>>
微信小程序一笔记账开发进度四
查看>>
bzoj 1070 费用流
查看>>
201671010139 徐楠 第四周总结
查看>>
JAVA链表简单实现
查看>>
[转载]T-SQL(MSSQL)语句查询执行顺序
查看>>
SignalR 行实时通信最大连接数
查看>>
开发进度6
查看>>
php方法重载
查看>>
三次握手和四次挥手(二)
查看>>
MySQL中的索引
查看>>
Android开发之手势滑动(滑动手势监听)详解
查看>>
switch
查看>>
HTTP错误code大全
查看>>
PAT Advanced Level 1043
查看>>
C++重载运算符练习--对people类重载“= =”运算符和“=”运算符
查看>>
Nmap命令的实用范例
查看>>
7-1 查找整数编程总结
查看>>