ajax的详细例子

前台

<form action="forget_phone_password2.asp" method="POST"  name="from1" id="from1">

<input name="username" type="text" class="wenben1" id="username" size="12" onBlur="_reg_checkusername();"/> <span style="padding-left:12px;" id="_checkusername_result" ></span><span style="padding-left:12px;" id="_checktel_result" ></span>

<input name="phone" type="text" class="wenben1" id="phone" size="12" onBlur="_reg_checktel();"/> <span style="padding-left:12px;" id="_checktel_result" >

<input type="button" class="btn" value=" 找 回 密 码 " id="_btn" onClick="regSubmit();" >

 

js..........................

<script language="javascript">
function _reg_checkusername(){
 if($("#username").val()!=""){
  $("#_checkusername_result").html("正在检查用户名…");
  $.post("/xml/_xml_reg_checkusername_a.asp",{ v:$("#username").val(), r:Math.random},
   function(xml){
    var r=getNodeValue(xml,'html_content');
       if(r==""){
        $("#_checkusername_result").html("");
       }else if(r=="0"){
        $("#_checkusername_result").html("<font color=#003300>没有此用户!</font>");
       }else if(r=="1"){
        $("#_checkusername_result").html("<font color=#2d8700>正确!</font>");
       }else{
        $("#_checkusername_result").html("<font color=#D60000>" + r + "</font>");
       }
   },"xml");
 }
}

function _reg_checktel(){
 if($("#phone").val()!=""&&$("#username").val()!=""){
  $("#_checktel_result").html("正在检查绑定状态…");
  
  
  $.post("/xml/_xml_phone_getuser.asp",{ v:$("#username").val(), r:Math.random},
   function(xml){
    var r=getNodeValue(xml,'html_content');
       if(r=="0"){
        $("#_checktel_result").html("<font color=#D60000>手机与帐号未绑定</font>");
       }else {
   
   if(r==$("#phone").val())
   {
         $("#_checktel_result").html("<font color=#2d8700>正确!</font>");
   }
   else
   {
    $("#_checktel_result").html("<font color=#D60000>手机与帐号未绑定</font>");
    }
   
       }
   },"xml");  
  
 }
}


function regSubmit(){
 $("#_btn").attr("disabled","disabled");
 var username = $('#username').val();
 if(username==''){
  alert('请填写用户名');
  $("#_btn").attr("disabled","");
 }

}

---------------------------------------------_xml_phone_getuser.asp--------------------

 

<%
nickname=formatStr(unescape(request("v")),20)
r = api_user_phone_queryinfo(nickname)

r = replace(r," ","")
if left(r,1) = "0" then
 if instr(r,"|")>0 then
  if split(r,"|")(4)<>"0" then
   r = split(r,"|")(4)
  else
   r = "0"
  end if
 else
  r = "0"
 end if
else
 r = "0"
end if


Response.Clear()
Response.Buffer = False
Response.Expires = -1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private"
Response.CacheControl = "no-cache"
Response.ContentType = "text/XML"
Response.Charset = "GB2312"

response.write("<?xml version=""1.0"" encoding=""GB2312""?>")
response.write("<root>" )
  response.write("<html_content>")
   response.write("<![CDATA[" & r & "]]>")
  response.write("</html_content>")
response.write("</root>")
%>

 

-------------------------涉及到的函数返回值-------------------

formatStr

 

function formatStr(val1,val2)
 temp=val1
 temp=trim(temp)
 charnum=val2
 temp=replace(temp,"'","""")
 temp=replace(temp,">","&gt;")
 temp=replace(temp,"<","&lt;")
 temp=left(temp,charnum)
 formatStr=temp
end function

 

 

 

api_user_phone_queryinfo

返回值

|李xxxxxx|130xxxxxx1518|1343xxxxxxxxx|2012-06-29 11:32:58

 

 

 

<%
'参数转码码表
set dic_spec_word = server.CreateObject("scripting.dictionary")
dic_spec_word.add "&","$0002"
dic_spec_word.add "#","$0001"
dic_spec_word.add "%","$0003"

 

function speccode(byval param, byref stat)
 dim items
 if instr(param,"$")>0 then
  stat = true
  param = replace(param,"$","$0000")
 end if
 for each items in dic_spec_word
  if instr(param,items)>0 then 
   stat = true
   param = replace(param,items,dic_spec_word(items))
  end if
 next
 speccode = param
end function

additional_url = "&encode=1"
%>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值