我在 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 服務器
uj5u.com熱心網友回復:
不要使用https,本地開發時使用http。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/322086.html
標籤:javascript css 节点.js 表达
下一篇:影片側邊欄
