Firefox 无法与位于 ws://192.168.0.155:5555/socket/server3.php 的服务器建立连接。
$(document).ready(function(){
if(!("WebSocket" in window)){
alert('not available');
}else{
_init();
}
});
function _init(){
var websocket;
var host = 'ws://192.168.0.155:5555/socket/server3.php';
try{
websocket = new WebSocket(host);
websocket.onopen = function(evt){ onOpen(evt); };
websocket.onclose = function(evt) { onClose(evt); };
websocket.onmessage = function(evt) { onMessage(evt); };
}catch(exception){
alert(exception);
}
}
function onOpen(evt){
$('.logger_screen').append('Connected');
}
function onClose(evt){
$('.logger_screen').append('Disconnected');
}
function onMessage(evt){
$('.logger_screen').append(evt.data);
}
我的代码有问题吗??