javascript代码实例教程-Jquery Ajax格式(备查)

发布时间:2019-02-21 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了javascript代码实例教程-Jquery Ajax格式(备查)脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。 $().ready(function () {

      $("#lo@R_406_2848@_button").click(function () {

        if($("#username").val()==null||$("#username").val()==''){

//alert("用户名不能为空");

                  $('#LOGinErrorMessage').htML('<p style="font-color:red;">用户名不能为空</p>');

return false;

}else if($("#password").val()==null ||$("#password").val()==''){

//alert("密码不能为空");

                  $('#loginErrorMessage').html('<p style="font-color:red;">密码不能为空</p>');

return false;

}else{

               $.ajax({   

               url: "/broute/MemberLogin/login/?"+Math.random(),

               error: function(msg) { alert(msg); },  

               complete: function (data) {

},

               data: {username: $("#username").val(), password: $("#password").val()},

               dataTyPE: "json",

               type: "get",

               success: function (data) {

               if(data.message=="success"){

           //window.location="/BRoute/MemberLogin/checkSession?"+Math.random();

                history.back();

                //location.reload();

                //location.replace(document.referrer);

                 } 

                 else{

                 // alert("用户名和密码不匹配");

                 $('#loginErrorMessage').html('<p style="font-color:red;">用户名和密码不匹配</p>');

                 }

      }

      });    

          }

          });

     });

 

 

 $(document).ready(function () {

            $.getJSON("/BRoute/MemberLogin/checkSession/?" + Math.random(), null, function (data) {

                //alert(data.message);

                if (data.message == "please login") {

                    //$('#huanying').html('<a href="https://localhost:20705/membermanage/memberlogin" class="B12-A" style="color:#006db6;">登录</a>');

                    //$('#logout').html('<a href="https://localhost:20705/membermanage/becomeMember" class="B12-A" style="color:#006db6;">注册</a>');

                }

                else {

                    VAR username = data.message;

                    $('#huanying').html('<a href="javascript:goto(0)" class="B12-A" style="color:#006db6;">欢迎您: ' + username + '!</a>');

                    //                    $('#logout').html('<a href="javascript:logout()"class="B12-A" style="color:#006db6;">退出</a>');

                    //                    $('#huanying').appendTo("<li id = 'logout'><a href='javascript:logout()' style='color:#006db6;'>退出</a></li>");

                    $("<li id = 'logout'><a href='javascript:logout()' style='color:#006db6;'>退出</a></li>").insertBefore($('#huanying'));

                }

            });

        });

       

   function logout() {

            $.ajax({

url: "/BRoute/MemberLogin/logout/?" + Math.random(),

error: function (msg) {

                         alert(msg);

                },

complete: function (data) {

                },

                data: null,

                dataType: "json",

                type: "get",

                success: function (data) {

                    window.location = "/?" + Math.random();

                    location.reload();

                }

});

        };

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! js脚本,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的javascript代码实例教程-Jquery Ajax格式(备查)全部内容,希望文章能够帮你解决javascript代码实例教程-Jquery Ajax格式(备查)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。