首页 > sockJS

sockJS

这是为的代码:

$(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里面的代码都会运行两次呢?求大神解答
【热门文章】
【热门文章】