页面,获值并且通过JSON
传值到后台
<form action="/api/setting/account.json" method="post" id="changeAccount-form">
<span>您是通过第三方登录注册的用户,为了您的使用方便,您可以修改您的登录账号</span>
<table class="binding-phone">
<tbody><tr>
<td>登录账号:</td>
<td>
<input name="Account[username]" type="text" value="qq_3aaa6586092b"> <span class="ft-red"> * </span>
</td>
</tr>
<tr>
<td>设置密码:</td>
<td><input id="password" name="Account[password]" type="password"><span class="ft-red"> * </span></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input id="re_password" name="Account[re_password]" type="password"><span class="ft-red"> * </span></td>
</tr>
<tr>
<td></td>
<td>
<button id="confirm" type="button" class="btn btn-yellow" data-loading-text="请求中...">确定</button>
</td>
</tr>
</tbody></table>
</form>
$(function(){
$('#confirm').click(function(){
var password=$('#password').val();
var re_password=$('#re_password').val();
if(password.length<=0){
alert("密码不能为空");
}else if(password==re_password){
console.log(password);
}else{
alert("两次密码不一致")
};
});
$.ajax(function{
url:'/settingpassword.xhtml',
data:{'password':password,'re_password':re_password},
method:'post',
sussccess:function(data){
alert("完成");
}
});
})
```我写的js但是没效果,去掉AJAX上一步就可以实现,反之