这是我的 HTML 代码:
<form id="change-ums" class="form-horizontal" style="margin-top: 10px;">
<div class="control-group">
<label class="control-label" for="umsid">ID :</label>
<div class="controls"><input type="text" id="umsid" required/></div>
</div>
<div class="control-group">
<label class="control-label" for="umspass">Password :</label>
<div class="controls">
<input type="password" id="umspass" required/>
<br>
<br>
<button type="submit" class="btn btn-primary btn-small">Change Pass</button>
</div>
</div>
</form>
这是我的 Jquery 代码:
$('change-ums').on('submit',function(e){
e.preventDefault();
$.ajax({
type : 'post',
url : '/user/changepass',
data : $('change-ums').serialize(),
success : function(){
alert('Your password has been changed successfully.');
}
});
});
我认为我做的一切都是正确的,甚至使用preventDefault()
但页面仍在刷新,jquery 无法完成其请求。我究竟做错了什么?