这是为的代码:
$(function () {
var websocket = new SockJS('http://localhost:8080/doob/sockjs/mywebsocket');
websocket.onopen = function (evnt) {
$("#msgcount").html("<p>"+ 'OK' +"</p>")
};
websocket.onmessage = function (evnt) {
$("#msgcount").append("<p>"+evnt.data+"</p>")
};
websocket.onerror = function (evnt) {
};
websocket.onclose = function (evnt) {
}
})
但是为什么每次收到消息onmessage里面的代码都会运行两次呢?求大神解答
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证0级讲师