发表于: 2021-01-05 00:29:50

1 1173


今天完成的事情:

完成任务5

学习JQuery AJAX 


了解xhl和html的区别:

https://blog.csdn.net/wlj323/article/details/48501353


了解什么是ajax,ajax的基本概念

Ajax的全称是Asynchronous JavaScript and XML,即异步JavaScript+XML。它并不是新的编程语言,而是几种原有技术的结合体


代码:

            $('#btn').click(function () {
                var user = $('#user').val();
                var pass = $('#pass').val();
                console.log(user);
                console.log(pass);

                /* $.ajax()写法 */
                var xhr = $.ajax({
                    type: 'POST',
                    data: {
                        name: user,
                        pwd: pass
                    },

                    url: '/carrots-admin-ajax/a/login',

                    success: function () {
                        // console.log()
                        var xhr = JSON.parse(xhr.responseText);
                        // console.log(xhr.code)
                        if (xhr.code == -5003) {
                            $('#hide').text('用户不存在');
                        } else if (xhr.code == -5004) {
                            $('#hide').text('密码不正确');
                        } else {
                            $('#hide').text('登陆成功');
                            location.assign("http://dev.admin.carrots.ptteng.com/"); //跳转网页
                        }
                    }
                });
            });


开始任务6


返回列表 返回列表
评论

    分享到