日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

Ajax教程之簡單應(yīng)用,檢測用戶名是否存在_AJAX教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:淺談我眼中的Ajax
AJAX在去年確實火爆了,作為Web2.0時代的核心技術(shù),關(guān)注度盛況空前,至今仍余音未絕,我一直從事于WinForm、Windows Mobile應(yīng)用開發(fā),雖然對Web開發(fā)略知一二,但從未向?qū)W習(xí)WinForm開發(fā)一樣系統(tǒng)的學(xué)過Web,最近閑暇之余從頭學(xué)了學(xué)ASP.NET,到現(xiàn)在才真正理解清

客戶端頁面index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ajax測試用戶名是否存在</title>
<script language="javascript" type="text/javascript">
//生成Http請求對象,用于客戶端向服務(wù)/端發(fā)送異步的http請求
function getHttpObject()
{
var http;
var browser = navigator.appName;

if(browser == "Microsoft Internet Explorer")
{
//如果用戶使用IE,就返回XMLHTTP的ActiveX對象
http = new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
else
{
//否則返回一個XMLHttpRequest對象
http = new XMLHttpRequest();
}

return http;
}
//獲取全局的HTTP請求對象
var http = getHttpObject();

//處理請求狀態(tài)變化
function getHello()
{
//4表示請求已完成
if (http.readyState == 4)
{

//獲取服務(wù)段的響應(yīng)文本

var helloStr = http.responseText;
alert(helloStr);
if(helloStr.charAt(0)!="0")
{alert("用戶名已經(jīng)存在!");}
else
{alert("用戶名不存在,可以實用!");}
}
}
function HelloWorld()
{
var url = "Check.aspx?id="+document.getElementById("Text1").value;

//指定服務(wù)端的地址
http.open("GET", url, true);
//請求狀態(tài)變化時的處理函數(shù)
http.onreadystatechange = getHello;
//發(fā)送請求
http.send(null);
}


</script>

</head>
<body>
<input id="Text1" style="width: 116px" type="text" />
<input id="Button1" type="button" value="button" onclick="javascript:HelloWorld();" />

</body>
</html>


服務(wù)器端功能頁面Check.aspx

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Check : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = "select Count(*) from Table where Name=" + Request.QueryString["id"].ToString() + "";
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Database;Integrated Security=True");
conn.Open();
SqlCommand cmd = new SqlCommand(str, conn);
int i = (int)cmd.ExecuteScalar();
conn.Close();
Response.Write(i);
}
}
 

 

分享:Ajax如何實現(xiàn)靜態(tài)頁面分頁
靜態(tài)頁面分頁的AJAX實現(xiàn),效果如圖: index.html頁面源文件: html head titleAJAX靜態(tài)分頁/title meta http-equiv=content-type content=text/html;charset=gb2312 style type=text/css !-- body { text-align:center;font:14px Verdana,sans-serif;

來源:模板無憂//所屬分類:AJAX教程/更新時間:2010-02-26
相關(guān)AJAX教程