简体   繁体   中英

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 ??

Effectively I am looking to update the page in the browser from node.js after the page has loaded and the connection closed ??

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. 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

  • use websockets. These are connections that stay open so you can pass messages back and forth while your page is running. Look it up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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