zoukankan      html  css  js  c++  java
  • ajax请求数据格式

    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

    本文来自博客园,作者:.net&new,转载请注明原文链接:https://www.cnblogs.com/wugh8726254/p/12644202.html

  • 相关阅读:
    mongodb导入导出
    python笔记1
    C# 文件下载断点续传
    热水维修记事
    memcached笔记
    模拟登陆
    Nginx学习笔记之加强篇
    Redis学习笔记之基础篇
    Nginx学习笔记之应用篇
    Nginx 学习笔记之安装篇
  • 原文地址:https://www.cnblogs.com/wugh8726254/p/12644202.html
Copyright © 2011-2022 走看看