我有一个包含登录名和密码形式的网页 如果登录名或密码错误,我该如何在golang中使用javascript alert()或console.log()函数进行响应
<body>
<!-- LOGIN FORM -->
<div class="login-page">
<div class="form">
<form class="login-form"action="/login" method="POST">
<input type="text" name="username" placeholder="username"/>
<input type="password" name="password" placeholder="password"/>
<button type="submit" id="send" value="Login">Login</button>
</form>
</div>
</div>
</body>
GOLANG
func (c *AuthenticationControllers) AdminLogin() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
http.ServeFile(w, r, "C:/Projects/Go/src/github.com/AlifElectronicQueue/web/template/login.html")
case "POST":
//********AUTHENTICATION PROCESS*********//
if loginAns {
//Some code
http.Redirect(w, r, "/admin/applications", 302)
} else {
http.Redirect(w, r, "/login", 302)
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
}