簡體   English   中英

為什么我的網站子網址在提交表單時不起作用,但在我手動輸入時起作用

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

我在 localhost:8080 上有一個表單,當您輸入表單數據(用戶和傳遞),然后按提交時,這意味着向 localhost:8080/submit 發送 POST,然后應該在該頁面上顯示文本,說“提交頁面”。 當我在瀏覽器中輸入“localhost:8080/submit”時,它可以工作,但是當我使用提交按鈕到達那里時,它顯示“此站點無法提供安全連接”(也就是,不起作用)

腳本.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(無法弄清楚如何使用這里的代碼片段,抱歉)

先感謝您! 我還不太熟悉 nodejs 服務器

不要使用https,本地開發時使用http。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM