zoukankan      html  css  js  c++  java
  • 家庭账本开发day11

    编写登录界面和个人信息查看界面

                $.ajax({
                        url: "UserServlet?method=login",//url
                        type: "post",//方法类型
                        dataType: "text",//预期服务器返回的数据类型 如果是对象返回的是json 如果是字符串这里一定要定义text 之前我就是定义json 结果字符串的返回一直到额error中去
                        data: $('#user').serialize(),//这个是form表单中的id   jQuery的serialize()方法通过序列化表单值
                        success: function (result) {
                            console.log(result);//打印服务端返回的数据(调试用)
                            if (result=="true") {
                                layer.msg('登录成功', function () {
                                    window.location = 'index.html';
                                });
                            }else{
                                layer.msg('用户名或密码有误');
                            }
                        }
                    });

    个人信息

        form.on('submit(info)', function(data){
            $.ajax({
                url:'UserServlet?method=info',
                type:'post',
                dataType: "json",//预期服务器返回的数据类型
                success:function(flag){
                    console.log(flag);
                    console.log(flag.data.username);

                    //var jsonObj = JSON.parse( flag );  
                    //console.log(jsonObj.data.money);
                    document.getElementById("musername").innerHTML=flag.data.username;
                    document.getElementById("mphone").innerHTML=flag.data.phone;
                    document.getElementById("memail").innerHTML=flag.data.mail;
                    document.getElementById("mmoney").innerHTML=flag.data.money;
                    layer.msg("查询成功",{icon:1})
                }
            });
        });

  • 相关阅读:
    Nginx
    Influxdb
    Gitlab
    Git
    Gogs
    Dockerfile
    Docker Data
    My Projects
    中文学习
    科技精选
  • 原文地址:https://www.cnblogs.com/zhukaile/p/14449191.html
Copyright © 2011-2022 走看看