Executing express.js scripts from bootstrap front-end | Sololearn: Learn to code for FREE!


Executing express.js scripts from bootstrap front-end

How would i go about runing some scripts i have written to be run on node server from my web application. I am still trying to figure out how to attach event listener from express app and any info or link to a great guide for that would be appreciated. Anyway, back on question. Is it possible i have like a separate js file attached to my DOM with <link src=""> tag where i import my express scripts and i can execute from DOM using an onClick() attribute.

2/1/2020 5:46:54 AM

Antony O. Onyango

4 Answers

New Answer


Use Post method, and your backend listen to data from frontend, and react accordingly. No use <script src="" > not <link ref="" >, use in the html file.


thanks alot, with some jquery in the dom it was possible to attach an event listener and make the post request back the the express server. Thanks man Gordon


You are welcome, Antony O. Onyango jQuery is heavy, long loading time. You can use vanilla JavaScript old syntax: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest new syntax: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API The fetch specification differs from jQuery.ajax() in three main ways: The Promise returned from fetch() won’t reject on HTTP error status even if the response is an HTTP 404 or 500.


Hi Antony, I think this code is kind of a suitable demonstration on how to use POST to send data to backend for generating content according, just in case you need an example for reference. https://code.sololearn.com/W9d2cR0D6P77/?ref=app