我的node.js应用程序遇到了一些问题,我不得不测试登录按钮的点击处理程序。即使我改变它(因此它不起作用),然后我点击它,那段代码仍然被执行。这是为什么?我清空了我的缓存。
最初它是#34;#sign-in"因为它是按钮ID。
$("#ign-in").on('click', function(event) {
event.preventDefault()
$.ajax({
url: '/api/sign-in',
method: 'POST',
data: {
email: $('#email').val(),
password: $('#password').val()
},
//success properyt meg fail propertyt kulon meghatarozni
success: function (response, request) {
window.location = response.redirectTo
},
error: function (jqXHR, textStatus, errorThrown) {
window.alert(JSON.parse(jqXHR.responseText).error.message)
}
})
})
HTML:
body
.container
form(class='form-signin' role='form')
h2.form-signin-heading Please Sign In
input#email.form-control(type='email' placeholder='E-mail address' required='' autofocus='')
input#password.form-control(type='password' placeholder='Password' required='')
div.checkbox
label(style="margin-top:5px; margin-bottom:5px; margin-left:0px;") Remember Me
input(type='checkbox' value='remember-me' style="margin-left:-110px;")
label
button#sign-in.btn.btn-lg.btn-primary.btn-block(type='submit') Sign In
button#forgot-pw.btn.btn-lg.btn-primary.btn-block(type='submit') Forgot Password?