zoukankan      html  css  js  c++  java
  • EXTJS 资料 Ext.Ajax.request 获取返回数据

    下面是一个登陆页面调用的EXTJS
    login function,通过  url: '/UI/HttpHandlerData/Login/Login.ashx',获取返回登陆账户和密码!


    Ext.onReady(function () { login = function (target) { if (eval(document.getElementById('TxtUserName')).value == "") { alert("提示! 请输入账户!"); return false; } else if (eval(document.getElementById('TxtPassword')).value == "") { alert("提示!请输入密码!"); return false; } else { var username = eval(document.getElementById('TxtUserName')).value; var password = eval(document.getElementById('TxtPassword')).value; Ext.Ajax.request({ url: '/UI/HttpHandlerData/Login/Login.ashx', method: 'POST', clientValidation: true, waitMsg: '正在提交数据...', waitTitle: '提示', params: { username: username, password: password }, success: function (response) { var data = Ext.decode(response.responseText); //设置Cookie new Extjs.cookie.set(data.userid, data.username); window.location.href = "../Page/InformationManagement/Index.html"; }, failure: function () { Ext.Msg.alert("提示", "登陆失败,请与管理员联系!"); } }); } } });

    后台代码:

    这是在一般处理程序中的代码:

      public void ProcessRequest(HttpContext context)
            {
    
    
                string username = context.Request.Form["username"];
                string password = context.Request.Form["password"];
                int intUserID = 0;
                DataSet ds = saBLL.Login(username, password);
    
                //客户端输出变量
                string strResult = string.Empty;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    //用户不存在
                    if (ds == null)
                        strResult = "{success:true,flag:false,msg:'用户不存在!'}";
                    //用户密码不正确
                    else if (ds.Tables[0].Rows[0]["Password"].ToString() != password)
                        strResult = "{success:true,flag:false,msg:'用户密码不正确!'}";
                    //正确
                    else
                    {
                        intUserID = Convert.ToInt32(ds.Tables[0].Rows[0]["AccountId"].ToString());
                        strResult = "{success:'true',flag:'true',userid:'" + intUserID + "',username:'" + ds.Tables[0].Rows[0]["LoginName"] + "'}";
                    }
                }
                else
                {
                    strResult = "{success:true,flag:false,msg:'用户不存在!'}";
                }
    
                //客户端输出
                context.Response.Write(strResult);
    
            }
  • 相关阅读:
    .Net/C# 应用程序直接读取本地 Cookies 文件(WinXP SP2 调用 API: InternetGetCookie 无果)
    wininet.dll函数库:不会过期的cookie
    WinForm中TextBox控件循环自动滚动示例
    JScript中Date.getTime转.Net中的DateTime
    js gettime c# ticks
    mysql查看整库个表详情
    rds分区实践
    mysql5.7.21源码安装
    EXPLAIN详解
    C#基础温习(4):C#中string数组和list的相互转换
  • 原文地址:https://www.cnblogs.com/foreverfendou/p/4323847.html
Copyright © 2011-2022 走看看