首页 > 代码库 > 老八系统简易调用AJAX

老八系统简易调用AJAX

 

<script src="http://www.mamicode.com/js/jquery-1.7.2.min.js"></script>
 <script>
        $(function(){
            $("#txtaccount").blur(function(){
                 $.post("check.asp",
                 {
                    name:$(this).val(),
                    type:"tjnickname"
                  },
                  function(data,status){
                      if(data=http://www.mamicode.com/=‘0‘){
                    $("#nicknamemsg").html("&nbsp;&nbsp;<font color=‘green‘>会员编号不存在</font>");
                      }
                      else{
                      $("#nicknamemsg").html("&nbsp;&nbsp;<font color=‘green‘> " + data + " </font>");
                      }
                  });
            });
        })
    </script>
  

check.asp

<!--#include file="inc/common.asp"-->
<%
    Response.ContentType = "text/html"
    Response.Charset = "GB2312"
    dim rs,sql,rs1,sql1
    opendb()
    if request.form("type")="useraccount" then
        set rs=server.CreateObject("Adodb.Recordset")
        sql="select 1 from members where User_Account=‘"&request("name")&""
        rs.open sql,con

        if rs.eof or rs.bof then
            response.Write "0"
        else
            response.Write "1"
        end if
         
        rs.close()
        set rs=nothing
    end if 

    if request.form("type")="tjnickname" then
        set rs=server.CreateObject("Adodb.Recordset")
        sql="select User_NickName from members where User_Account=‘"&request("name")&"‘ and User_Check = 1"
        rs.open sql,con

        if rs.eof or rs.bof then
            response.Write "0"
        else
            response.Write rs("User_NickName")
        end if
         
        rs.close()
        set rs=nothing
    end if 

    if request.form("type")="regcenter" then
        set rs=server.CreateObject("Adodb.Recordset")
        sql="select User_ID,Reg_Center_ID from Reg_Center where Reg_Center_Code=‘"&request("name")&"‘ and Reg_Check = 1"
        rs.open sql,con
        if rs.eof or rs.bof then
            response.Write "0"
        else
            set rs1=server.CreateObject("Adodb.Recordset")
            sql1 = "select User_NickName from members where User_ID="& rs("User_ID") &""
            rs1.open sql1,con
            response.Write rs1("User_NickName")
            rs1.close()
            set rs1 = nothing    
        end if
        rs.close()
        set rs = nothing
       
    end if 

    closedb()
%>