How to send data back and forth from NodeJs Express and Html
تبليغيرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.
I want to send data from NodeJs Backend to HTML Webpage and get the user modified data back to NodeJs.
Here is my NodeJs File:
const app = express()
app.use(express.static(‘views’));
var server = app.listen(3000, function() {
var port = server.address().port
console.log(‘Express app listening at %s’, port)
})
And here is my html file in views Folder which also has some style files and Prism.js files:
<head>
<title> Document </title>
<link href=”prism.css” rel=”stylesheet” />
<script src=”prism.js”></script>
</head>
<script src=”stylefile.js”></script>
<body>
Hello User
<textarea id=”editing” spellcheck=”false” oninput=”update(this.value);
sync_scroll(this);” onscroll=”sync_scroll(this);
onkeydown=”check_tab(this, event);”>Some C Program here</textarea>
<pre id=”highlighting” aria-hidden=”true”>
<code novalidate class=”language-c”
id=”highlighting-content”>The same C Program displayed here with syntax-highlighted</code>
</pre>
<button>Submit</button>
</body>
Now, I want to send initial C program data as text variable from NodeJs server to HTML to display in the textarea, allow the user input to modify the initial program data and submit, and get the modified program back to the NodeJs server as text variable.
How can this be done?
أضف إجابة