0

I have a button in HTML:

<button id="save" type="button" onclick="save()">Save</button>

and in javascript I want it to run something in node.js, something that's not client side.

So something like this is what I am looking for:

function save() {
    //run script from server
}

And if this script MUST be ran as if I was typing node script.js

The reason the script has to be ran as if I was typing it was because it's saving a file to the node.js server, a json to be exact, and that file must be on the node.js server for my application.

1 Answer 1

2

So you really can't execute a server-function from the client side, but you can maybe send a post-request and call the function on the server side, or you can use sockets to communicate with the server. Either way, it would be horrible security-wise, if you would be able to interact with the server on that way.

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

Comments

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.