0

I'm currently using Node.JS to back end into different systems. From my web page I want to be able to call a function in the Node.JS script and have it return some values.

Here is a diagram of what I mean.

JS --> calls function --> node.js --> executes function called by normal js

1
  • And what about AJAX? Commented Oct 1, 2016 at 19:50

1 Answer 1

2

The JS on your browser lives in the client machine. The JS on your Node.js lives in the server machine. There's this great divide between them called The Internet, so you technically cannot "have JS from HTML call a function INSIDE a node.js script".

What you do instead is make a network request from your browser JS over The Internet to your server JS and have it respond. There's many ways to do this, most common of which is AJAX.

Sign up to request clarification or add additional context in comments.

3 Comments

called The Internet :-)
@baao I could have called the server machine "The Cloud" to make it sound more magical. :D
Thank you very much, I thought I was missing something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.