I have been having trouble with ajax, and I just want my html to pass a function when a button is passed, but that function is in a node.js file.
How could I do this without AJAX, and if AJAX is required, could I be linked code?
Create index.js
file and attach it to your html (index.html)
file.
Then in html
file if you are submitting form then pass onClick=functionName()
as attribute
in <form>
tag.
In index.js
file, you can add functionName
function and that function works as your frontend
function.
Use axios
or inbuild request
to fetch data from that function via endpoint
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.