一只会飞的白菜 2017-11-20 08:53 采纳率: 0%
浏览 1838

HTML 通过json 传值,到后台

页面,获值并且通过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上一步就可以实现,反之


  • 写回答

2条回答 默认 最新

  • doggy_coder 2017-11-20 09:08
    关注

    js和ajax就可以了

    评论

报告相同问题?

悬赏问题

  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误