首页 > Web开发 > 详细

ajaxi请求数据格式

时间:2020-04-06 21:35:25      阅读:82      评论:0      收藏:0      [点我收藏+]

type是请求的类型包含了get和post

url:请求的地址

data:传递的参数

dataType :数据格式,可以是html,json

返回成功之后进入到success 函数

返回失败之后进入到error函数

 

 <script type="text/javascript">

        function doLogin(type) {
            $.ajax({
                type : "GET",
                url : "login.do",
                data : {
                    username : $("#username").val(),
                    password : $("#password").val(),
                    type : type
                },
                dataType : "json"//预期服务器返回的数据
                success : function(data) {
                    if (data.errCode < 0) {
                        alert("登录失败!")
                        $("#errMsg").show().html(data.errMsg).stop(truetrue)
                                .fadeOut(3000);
                    else {
                        //登录成功,做其他处理
                        alert("恭喜你,登录成功!");
                    }
                }
            });
        }
    </script>
转载博客:https://www.cnblogs.com/1906859953Lucas/p/10828801.html

ajaxi请求数据格式

原文:https://www.cnblogs.com/wugh8726254/p/12644202.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!