开发者

Socketio wont run, getting io.connection not a function

Using this code on the client side:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
    <scri开发者_JAVA技巧pt src="http://cdn.socket.io/stable/socket.io.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
                var socket = io.connect('http://localhost:8888');
});
</script>

Getting this error:

"io.connect is not a function"

Any suggestions?


The answer was I had to use my external ip address for the server this script is running on.


The biggest problem is that http://cdn.socket.io/stable/socket.io.js is code for Socket.IO 0.6 and you are using the Socket.IO 0.7+ API.

The CDN has been deprecated and should no longer be used. Here is a wiki about how to serve the socket.io client in your HTML pages: https://github.com/LearnBoost/Socket.IO/wiki/How-do-I-serve-the-client

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜