socket.io, io is not defined (JS Error)

前端 未结 9 768
你的背包
你的背包 2021-01-03 20:33

I have just started with socket.io, its giving JS Error on client page

io is not defined

How to fix this ?

相关标签:
9条回答
  • 2021-01-03 21:10
    <script src="http://cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
    

    this is the latest version of socket.io to be included.

    0 讨论(0)
  • 2021-01-03 21:16

    Wrap your client code on a '$(document).ready()' for jQuery or another library similar function. This way you'll be sure your code runs after the library beeing loaded.

    0 讨论(0)
  • 2021-01-03 21:19

    Alternatively you can use the Socket.io CDN:

    <script src="https://cdn.socket.io/socket.io-1.0.0.js"></script>
    
    0 讨论(0)
提交回复
热议问题