ASP和AJAX應(yīng)用一例,檢測(cè)注冊(cè)用戶是否有效
http://www.uqqb.com 2009/2/24 21:00:59 深山行者 字體:
大 中 小 瀏覽 4065
t1.html
<script language="javascript" type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer() {
var u_name = document.getElementById("u_name").value;
if ((u_name == null) || (u_name == "")) return;
var url = "cu.asp?name=" + escape(u_name);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
if (xmlHttp.readyState < 4) {
test1.innerHTML="loading...";
}
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
test1.innerHTML=response;
}
}
</script>
<form name="form1" action="t1.asp" method="post" autocomplete="off">
用戶名: <input type="text" name="u_name" id="u_name" />
<span id="test1">是否能注冊(cè)</span><br>
密 碼:<input type="password" />
<input type="submit" value="注冊(cè)" />
</form>
cu.asp
<%
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "No-Cache"
%>
<!--#i nclude file="conn.asp"-->
<%
name=request.querystring("name")
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from u_ser where u_name='"&name&"'"
rs.Open sql,conn,1,1
if rs.eof and rs.bof then
response.write("true")
else
response.write("false")
end if
rs.close
set rs=nothing
call CloseDatabase
%>
- 相關(guān)閱讀
- 一個(gè)非常適和div+css初學(xué)者看的例子,看完之后,相信你的DIV+CSS技術(shù)一定會(huì)上一個(gè)層次
- 網(wǎng)上購(gòu)物車購(gòu)物數(shù)量加減效果
- 搜索引擎優(yōu)化八個(gè)基礎(chǔ)的知識(shí)
- 購(gòu)買系統(tǒng)可以免費(fèi)提供修改服務(wù)嗎?
- 極酷的,漂亮的頁面loading等待頁面特效(2)
- windows顏色選擇框
- 利用java控制圖片的大小
- 青島景色旅程
- 共有0條關(guān)于《ASP和AJAX應(yīng)用一例,檢測(cè)注冊(cè)用戶是否有效》的評(píng)論
- 發(fā)表評(píng)論