0

I'm fairly new to using none basic code (I.E. jquery, node.js,and the like) And I couldn't find a way to create and save an html document on the server. I've been told that node.js has no DOM manipulation, but does it have what it needs to make an html page?(I.E a file named "first.html" that contains "<!doctype html><html></html>" I'm also open to using ajax, but I'm not even sure how to get new libraries into my project (Using cloud 9 with github) I'm working in chrome, and this project is just for me, so screw internet explorer.

1 billion points to a house of your choice if someone can find a way to do it with just js, because there is supposedly a way to get it to run server side.

Another note, this project may end up being used totally offline, as in client only? I'm not sure how that would affect things like jquery and node.js though

Spencer Cornwall
  • 289
  • 2
  • 14
  • Possible duplicate of https://stackoverflow.com/questions/2496710/writing-files-in-node-js – zipzit Jun 06 '17 at 16:06
  • You can use the [`fs`](https://nodejs.org/api/fs.html) module to read and write any file you want on the server – d4nyll Jun 06 '17 at 16:07
  • Possible duplicate of [Writing files in Node.js](https://stackoverflow.com/questions/2496710/writing-files-in-node-js) – zipzit Jun 06 '17 at 16:08
  • `this project may end up being used totally offline, as in client only?` . That doesn't make any sense. Node.js is a server tool. You can run the server on your localhost, offline, but the words "client only" just don't fit. – zipzit Jun 06 '17 at 16:11
  • "I'm also open to using ajax" — Ajax is the term given to *making an HTTP request from a browser without leaving the page*. It makes no sense in the context of either Node or generating HTML. – Quentin Jun 06 '17 at 16:12
  • "I couldn't find a way to create and save an html document on the server" — This sounds like an [XY problem](http://xyproblem.info/). What is your broader goal? – Quentin Jun 06 '17 at 16:13
  • "I've been told that node.js has no DOM manipulation" — There are plenty of libraries that perform DOM manipulation available for Node. – Quentin Jun 06 '17 at 16:13
  • "does it have what it needs to make an html page?" — In the context of Node, people *usually* use a templating language (such as nunjunks) for that … but I've no idea if that is appropriate for whatever you are doing. – Quentin Jun 06 '17 at 16:14
  • Thanks for the nigh instant feedback, I'm filling a folder on my server with items of a list, each html file being one line of my list, I'm trying to figure out a way to get stuff (like text box content, and whether certain check boxes are checked, and such) and use that to create an html file that I can load into wherever I need – Spencer Cornwall Jun 06 '17 at 16:19
  • also, @Quentin, I was thinking of quickly opening a new html page with php to do this? Grab the check box states and text from text boxes and save it via php, would that work? – Spencer Cornwall Jun 06 '17 at 16:23

0 Answers0