Search code examples
phpnode.jslong-polling

Controlling just an element from an existing page with nodejs


I'm having a web application build in PHP and I would like to add some real-time functionality to it. What I actually need is to control jut some parts (notifications "elements") of an existing page with nodejs. Would that be possible? I don't want to have to rewrite all the page on node.js.

I'm trying to find out if node.js could be the best approach for my needs (I never worked with it) or if it's better to use ajax long polling.

I read about using PHP and nodejs together, and about building one upon the other but I didn't found an answer about the situation I described before.


Solution

  • Node.js is a server side application plattform, so you cant use it in the Browser directly.

    If you want to add realtime functionality to your site, you first have to think about the transport architecture. Either you use ajax with polling or you use websockets (e. g. with socket.io). In both cases you will need a serverside application to handle this.

    This could be either PHP or Node or any other server side thing.