Understanding some aspects of node.js
javascript, node.js
Solution
When you install node.js where do you store your files so that the web browser can display your content? For example Apache have a www folder.
Wherever you want. node.js doesn't serve static content, it runs JavaScript. You tell it which script to run when you start it.
You could write some JavaScript that serves static content, but where you would keep it depends on the code you wrote.
Does node.js replace client side javascript?
Only in so far as any server side programming replaces client side JavaScript.
One advantage of using JS on the server side is that you can reuse libraries on both the client and the server. See Mojito for a framework that claims to focus on this (I haven't had time to try it myself yet).
For example if I wanted to put data from the server into this div element `<div id="content"></div>` In PHP you could do something like this: `<div id="content"><?php echo $content; ?></div>`
PHP is a template language with an embedded programming language. JavaScript is a programming language. Typically you would use a template language (e.g. moustache) from your JS.
Would you ever call node.js from client side? For example: An Ajax request to node.js to get data.
Yes, if you want to. Just like any other server side programming environment. (Assuming you are using node to run an HTTP server).
Problem
There are a couple of aspects of node.js I don't quite understand. I hope someone can make things clearer When you install node.js where do you store your files so that the web browser can display your content? For example Apache have a www folder. Does node.js replace client side javascript? How does node.js interact with HTML? For example if I wanted to put data from the server into this div element `<div id="content"></div>` In PHP you could do something like this: `<div id="content"><?php echo $content; ?></div>` Would you ever call node.js from client side? For example: An Ajax request to node.js to get data. Whats confusing me is that because it is run from the server then I expect that I can use javascript on the browser to get data from the node.js server. However, examples I seen this is never done. Thanks in advance