zoukankan      html  css  js  c++  java
  • jQuery异步提交

    引用jquery文件:

     <script src="JQuery/jquery.js" type="text/javascript"></script>
        <script src="JQuery/jquery.min.js" type="text/javascript"></script>
    调用js:

    function check()
    {
        if (document.getElementById_x("username").value=="")
        {
             alert("请输入用户名")
             document.getElementById_x("username").focus();
             document.getElementById_x("username").select();
             return false;
         }
        if (document.getElementById_x("pwd").value=="")
        {
             alert("请输入密码!")
            document.getElementById_x("pwd").focus();
             document.getElementById_x("pwd").select();  
             return false;
        }
        if(document.getElementById_x("yanzheng").value == "")
        {      
              alert("请输入验证码!");
              return false;
        }
        $.post("Chuli/login.aspx",{name:$("#username").val(),pwd:$("#pwd").val(),yanzheng:$("#yanzheng").val()},resultss);
        return true;
    }

    //返回结果调用方法
    function resultss(ee)
    {
        if (ee == "error") 
        {      
            alert("用户名或者密码错误,登录失败!");       
        }
        else if(ee == "yanerror")
        {
            alert("验证码填写错误!"); 
        }
        else 
        {
            if (ee == "mansuccess")
            {
                window.location.href("HouTai/index.aspx");
            }
            else  
            {
                 window.location.href("index.aspx");
            } 
       }
    }

    //新建异步调用页面:

    后台方法:

     protected void Page_Load(object sender, EventArgs e)
        {
            string name = Request.Params["name"];
            string pwd = Request.Params["pwd"];
            string yan = Request.Params["yanzheng"].ToUpper();
            string pwds = pwd + pwd;
            UserManager uman = new UserManager();
            bool b = uman.Login(name, pwds);
            if (b==true)
            {
                Session["users"] = name;
                string yans = Session["yan"].ToString().ToUpper();
                if (!(yans.Equals(yan)))
                {
                    Response.Write("yanerror");
                }
                else if (name.Equals("shiny"))
                {
                    Response.Write("mansuccess");
                }
                else
                {
                    Response.Write("success");
                }           
            }
            else
            {
                Response.Write("error");
            }
            Response.End();
        }

    关于我:懂些前端,懂些后端,懂些数据库,伪全栈开发者。
  • 相关阅读:
    Redis的高可用详解:Redis哨兵、复制、集群的设计原理,以及区别
    高并发架构系列:Redis为什么是单线程、及高并发快的3大原因详解
    Docker安装Zookeeper并进行操作
    org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
    SpringBoot启动加载yml配置文件出现编码格式错误
    log4j:WARN No appenders could be found for logger ().解决方案
    SpringBoot&Dubbo&Zookeeper远程调用项目搭建
    Postman下载与安装
    echart 饼图图例legend支持滑动
    web app 开发必不可少的滑动插件 Flipsnap
  • 原文地址:https://www.cnblogs.com/shinggang/p/2001315.html
Copyright © 2011-2022 走看看