AJAX之xmlHttp_AJAX教程
推薦:淺析AJAX初體驗之上手篇HotHeart的BLog: www.xujiwei.cn/blog AJAX初體驗之上手篇 AJAX是這兩年蠻熱的東西,我也湊湊熱鬧,前些天去找了些教程學學,下面就按整個處理過程把自己學的東西寫寫,不過,因為是初學,所以有錯誤就請見諒啦,歡迎指正^_^。 1.創建 XMLHttpRequest 對象
<script type="text/javascript" language="javascript">
<!--
//以XML求取數據
function XmlPost(theEmail)
{
var webFileUrl = "../User/CheckUser.aspx?LogonName=" + theEmail;
var result = "";
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
//var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send("");
xmlHttp.onreadystatechange=function()
{
if (xmlHttp.readyState==4)
{
result = xmlHttp.responseText;
}
}
if(xmlHttp.status!=200)
{
alert ('網絡故障(xmlHttp.status='+xmlHttp.status+'),請稍后再試!');
}
result = xmlHttp.responseText;
result = result.substring(0,result.indexOf("?EX"));
if(result != "false")
{
return true;
}
else
{
return false;
}
}
//-->
</script>''' <summary>
''' 檢測用戶是否存在<文件名:../User/CheckUser.aspx>
''' </summary>
''' <remarks>Created by dzh @2006/06/27 18:22</remarks>
Partial Class Web_User_CheckUser
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Request.QueryString("LogonName") Is Nothing Then
Response.Write("false" + "?EX")
Response.End()
Exit Sub
End If
If (New EasyClick.EasyBusiness.UserBusiness).GetUserByLogonName(Request.QueryString("LogonName").ToString) Is Nothing Then
Response.Write("false" + "?EX")
Response.End()
Exit Sub
Else
Response.Write("true" + "?EX")
Response.End()
Exit Sub
End If
End Sub
End Class
分享:如何掌握AJAX之AJAX通訊技術當在網上沖浪時,將在瀏覽器和服務器之間存在大量的請求。最初,所有的這種請求都是在用戶做出需要這一步驟的明顯操作時發生的。Ajax技術將開發人員從等待用戶做出這樣的操作中解放出來,允許他在任何時間創建一個對服務器的調用。 Ajax通信支持許多不同的技
- 相關鏈接:
- 教程說明:
AJAX教程-AJAX之xmlHttp
。