简体   繁体   中英

Why doesnt my website sub url working when submitting form but works when i manually enter it

I have a form on localhost:8080 which when you enter form data (user & pass), then press submit, it meant to send a POST to localhost:8080/submit, then should show text on that page saying "Submit page". When I enter "localhost:8080/submit" into my browser, it works, but when I use the submit button to get there, it says "This site can't provide a secure connection" (aka, doesn't work)

script.js

 const url = "https://localhost:8080"; const data = { "user": "user", "pass": "pass" } function send() { alert("Sent") $.post(url, data, function (data, status) { console.log("Sent " + data + ", status is: " + status) }); }
 body { background-color: #444444; } .form-div { width: 100%; height: auto; text-align: center; justify-content: center; align-content: center; border: 1px solid red; } form { color: white; }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Harley Swift</title> <link rel='stylesheet' href='styles.css'/> <script type="text/javascript" src="script.js"></script> </head> <body> <div class="form-div"> <form method="POST" action="https://localhost:8080/submit"> <div> <label for="user">Username</label> <input name="user" type="text" id="user"><br> </div> <div> <label for="pass">Password</label> <input name="pass" type="password" id="pass"><br> </div> <br> <div> <button class="btn" onclick="send()">Submit</button> </div> </form> </div> </body> </html>

app.js: https://hastebin.com/udunalurub.lua (couldn't figure out how to use code snippets on here, sorry)

Thank you in advance! I am not too familiar with nodejs servers yet

不要使用https,本地开发时使用http。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM