NodeJS 当点击按钮而不是打开页面时下载ejs文件

46scxncf  于 2023-06-22  发布在  Node.js
关注(0)|答案(1)|浏览(126)

我做了一个ejs页面(patients.ejs),如果点击doctor.html页面的按钮,数据库的数据将显示在这里。但是当我点击这个按钮时,patients.ejs下载对话框出现,而不是打开那个页面。我已经将patients.ejs与doctor.html的按钮链接起来
下面是doctor.html的代码

<div class="sign-in">
       
        <form action="/doctor" method="post" enctype="application/x-www-form-urlencoded">
            <label for="name">Name:</label> 
            <input type="text" name="name" placeholder="enter your name">
            <br/>
            <br/>
            <label for="phone_number">Mobile:</label>
            <input type="text" name="phone_number" placeholder="enter your mobile number">
            <br/>
            <br/>
            <label for="password">Password:</label>
            <input type="password" name="password" placeholder="enter your password" />
            <br />
            <br />
            <button id="btnsubmit" class="btn" onclick="submit"><a href="patients.ejs">Submit</a></button>
        </form>
    </div>

我期待打开patients.ejs文件,但当单击doctor.html的提交按钮时,出现下载对话框

93ze6v8z

93ze6v8z1#

由于ejs是一个服务于站点的框架,所以

<a href="patients.ejs">Submit</a></button>

将ejs文件与html文件链接时不起作用
所以我用这个

<a href=\"/patients\">Submit</a></button>

所以我用了这个,它起作用了...

相关问题