Reputation: 411
I have a few plain text files from which I would like to take some strings and render them into an HTML file. The problem is that since nodeJs, which is what I am using to parse file data, is a server-side technology, I can't just link the nodeJs file to the html with something like <script type="text/javascript" src="./homepage.js"></script>
and call something like document.querySelectorAll('area');
in the javascript file to get an element whose content I can customize. I have a nodeJs file that retrieves and manipulates data taken from the files. I want to manipulate this data and render it into the html file as I would usually do for a regular javascript file (using query selectors and the such). So how might I be able to take some data from my file system and render it into a certain html file?
Upvotes: 1
Views: 333
Reputation: 26538
Presuming you are using nodejs to render your html file, there are 3 ways:
<script type="text/javascript" src="http://your_nodejs_server/data.js"></script>
which will fires a request to your nodejs server which will render the js file containing your data dynamicallyUpvotes: 2