一只会飞的白菜 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 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配