智云SRM-WEBAPI(目前客户通用API)
1
yusijie
2024-06-07 6d333439f8abe3f39de1ab393007009d570c6256
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="Scripts/jquery-1.6.4.min.js"></script>
    <script src="Scripts/jquery.signalR-2.4.2.min.js"></script>
    <script src="http://localhost:8082/SRMAPI/signalr/hubs"></script>
    <script type="text/javascript">
        $(function () {
            // 引用自动生成的集线器代理
            var chat = $.connection.chatHub;
            // 定义服务器端调用的客户端sendMessage来显示新消息
            chat.client.Send = function (title, message) {
                // 向页面发送接收的消息
                sendMsg();
            };
            // 集成器连接开始
            $.connection.hub.start().done(function () {
                sendMsg();
                // 服务连接完成,给发送按钮注册单击事件
                $('#sendmessage').click(function () {
                    // 调用服务器端集线器的Send方法
                    chat.server.send($("#title").val(), $('#message').val());
                });
            });
        });
 
        function sendMsg() {
            var options = {
                url: "Message/MsgCount",
                type: 'post',
                success: function (data) {
                    $("#count").html(data.count);
                }
            };
            $.ajax(options);
        }
    </script>
</head>
<body>
    <h2>
        发送消息
    </h2>
    <div>
        <label>我的消息:</label>
        <span style=" color:red; font-size:30px;" id="count"></span>条
    </div>
    <p>
        <div>
            标题:
            <input type="text" id="title" />
        </div>
        <br /><br />
        <div>
            内容:
            <textarea id="message" rows="4" cols="30"></textarea>
        </div>
        <br /><br />
        <div>
            <input type="button" id="sendmessage" value="发送" />
        </div>
    </p>
</body>
</html>