I want to continuously keep sending update to server using jquery. The interval will be almost nil. What are the best way to do this? This is for updating the cursor position of once person on others screen. Practical implementation will be in a prototype of HTML5 whiteboard.
我想继续使用jquery继续向服务器发送更新。间隔几乎为零。最好的方法是什么?这是为了在其他屏幕上更新一个人的光标位置。实际的实现将是HTML5白板的原型。
- What are the options available.
- 有哪些选择。
-
Which is the best way and what are the implications.
哪种方式最好,有什么影响。
function send_position(){
function send_position(){
//code to post
//要发布的代码
}
}
setInterval( "send_position()", 10 );
setInterval(“send_position()”,10);
Will this method be ok?
这种方法可以吗?
2 个解决方案
#1
1
Either by using window.setTimeout() as described by Robert or, if you already use HTML5, you could use websockets: http://code.google.com/p/jquery-websocket/
通过使用Robert描述的window.setTimeout(),或者,如果您已经使用HTML5,则可以使用websockets:http://code.google.com/p/jquery-websocket/
#2
0
You can use jQuery/xmlhttprequest for that:
您可以使用jQuery / xmlhttprequest:
windows.setTimeout and $.post()
windows.setTimeout和$ .post()
#1
1
Either by using window.setTimeout() as described by Robert or, if you already use HTML5, you could use websockets: http://code.google.com/p/jquery-websocket/
通过使用Robert描述的window.setTimeout(),或者,如果您已经使用HTML5,则可以使用websockets:http://code.google.com/p/jquery-websocket/
#2
0
You can use jQuery/xmlhttprequest for that:
您可以使用jQuery / xmlhttprequest:
windows.setTimeout and $.post()
windows.setTimeout和$ .post()