简体   繁体   English

从Node.js更新客户端DOM

[英]Updating Client Side DOM from Node.js

I have re-written this description as the original was not clear at all, I think I can summarize this much easier with: 我重新写了这个描述,因为最初的描述根本不清楚,我想我可以用以下方法更容易地总结一下:

using node.js, is it possible to update the client side DOM without leaving the original connection open that created the page headed and body, and doing a response.write() with each new update ?? 使用node.js,是否可以更新客户端DOM,而无需打开原始连接来创建页眉和页眉,并在每次新更新时都执行response.write()?

Effectively I am looking to update the page in the browser from node.js after the page has loaded and the connection closed ?? 实际上,我正在寻找在页面加载并关闭连接后从node.js更新浏览器中的页面的方法。

Thanks 谢谢

The way I see it, this has nothing to do with whether you use node.js or PHP or whatever, if you want to modify the DOM on the client side, after the HTTP request finishes, these are your two options. 我认为,这与使用node.js还是PHP无关,如果要在客户端修改DOM,则在HTTP请求完成后,这是您的两个选择。 Either you 要么你

  • use a combination of javascript's setTimeout() and requests to the XHR object to poll a JSON or HTML fragment (I won't go into AJAX polling here), or 使用javascript的setTimeout()和对XHR对象的请求的组合来轮询JSON或HTML片段(我将不在这里进行AJAX轮询),或者

  • use websockets. 使用websockets。 These are connections that stay open so you can pass messages back and forth while your page is running. 这些连接保持打开状态,因此您可以在页面运行时来回传递消息。 Look it up. 查一下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM