从前端 Javascript 渲染 EJS 模板页面......>
我有一个 Node/Express/EJS 后端以及通常的 HTML/CSS。 JavaScript 前端。
显然,我通过 API 从后端管理页面渲染,但我有一个用例,其中前端页面(用户设置)上有一个用于重置用户密码的按钮。 页面上的标准 HTML 为:
<input class="submit__button" type="button" value="Submit Changes">
然后在 HTML 页面的底部,我像您一样调用 JS 文件:
<script src="/js/usrSettings.js"></script>
在 .js 文件中,我尝试从后端呈现一个 ejs 模板,该模板具有重置 a 的所有逻辑这样做的密码:
// Redirect to the Reset Password Page when button clicked
const pwdChange = document.getElementById('submit_pwdChange');
pwdChange.addEventListener('click', function () {
const pwdReset = ejs.render('pwdReset', { layout: './layouts/noLayout', title: 'Apotheosis - Reset Password' });
});
这不起作用,我在前端控制台日志中没有收到任何错误消息,在后端也没有收到任何错误消息,但它只是不执行任何操作,不渲染页面,不崩溃,什么都没有。
我想知道如何从前端 javascript 调用 EJS 模板来重定向到该 html 页面?
任何建议都非常感激。
干杯, M。
I have a Node / Express / EJS backend with the usual HTML / CSS . Javascript front end.
I obviously manage the page rendering from the backend through APIs but I have a Use Case where a front end page (User Settings) has a button on it to Reset the User password.
Standard HTML on the page with:
<input class="submit__button" type="button" value="Submit Changes">
and then at the bottom of the HTML Page Im calling the JS file as you would:
<script src="/js/usrSettings.js"></script>
and in the .js file, Im trying to render an ejs template from the backend which has all the logic to reset a password by doing so:
// Redirect to the Reset Password Page when button clicked
const pwdChange = document.getElementById('submit_pwdChange');
pwdChange.addEventListener('click', function () {
const pwdReset = ejs.render('pwdReset', { layout: './layouts/noLayout', title: 'Apotheosis - Reset Password' });
});
This doesnt work, Im not getting any error msgs either in the front end console Log, nor in the back end but it just doesnt do anything, doesnt render a page, doesnt crash, nothing.
I was wondering how one would go about calling an EJS template from the front end javascript to redirect to that html page?
Any suggestions greatly appreciated.
Cheers,
M.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论