Ajax¼ì²â×¢²áÓû§ÊÇ·ñ´æÔÚ(.NET)
HTML´úÂëÈçÏÂ:
LoginValidate.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginValidate.aspx.cs" Inherits="LoginValidate" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ÑéÖ¤Óû§ÃûÊÇ·ñ´æÔÚ</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
//´¦Àí·½·¨
function CheckUserName()
{
createXMLHttpRequest();
var url= "LoginValidate.ashx?username="+document.getElementById("username").value;
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=ShowResult;
xmlHttp.send(null);
//document.getElementById("Msg").innerHTML='';
}
//»Øµ÷·½·¨
function ShowResult()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status=
Ïà¹ØÎĵµ£º
XMLHttpRequest ¶ÔÏóÊÇAJAX¹¦ÄܵĺËÐÄ£¬Òª¿ª·¢AJAX³ÌÐò±ØÐë´ÓÁ˽âXMLHttpRequest ¶ÔÏó¿ªÊ¼¡£
Á˽âXMLHttpRequest ¶ÔÏó¾ÍÏÈ´Ó´´½¨XMLHttpRequest ¶ÔÏó¿ªÊ¼£¬ÔÚ²»Í¬µÄä¯ÀÀÆ÷Öд´½¨XMLHttpRequest ¶ÔÏóʹÓò»Í¬µÄ·½·¨£º
ÏÈ¿´¿´IE´´½¨XMLHttpRequest ¶ÔÏóµÄ·½·¨£¨·½·¨1£©£º
var xmlhttp = new ActiveXObject("Msxml2.XMLH ......
ÎÒ×Ô¼ºÐ´¸ö¿ìËÙÈëÃŵÄASP.NETµÄÍêÈ«¿ÉÊÓ»¯Ajax¿ª·¢£¬ÓÃVisual studio2008ÀïÃæ×Ô´øµÄAJAX Extensions¿Ø¼þ¡£
1£¬Ê×ÏÈ£¬ÍùÒ³ÃæÀïÃæקһ¸öScriptManager¿Ø¼þ£¨×¢²á½Å±¾£¬±ØÐëÔÚËùÓзþÎñÆ÷¿Ø¼þ֮ǰ³öÏÖ£©
2£¬ÍùÒ³ÃæÀïקһ¸öUpdatePanel¿Ø¼þ£¨¾Ö²¿Ë¢Ð¿ؼþ£©
3£¬ÔÚUpdatePanel¿Ø¼þµÄÃæ°åÀקһ¸öTextBox¿Ø¼þTextBox1ºÍÒ»¸öLa ......
xmlHTTP¶ÔÏóµÄÎÊÌâ Ç°Á½Ìì°²×°ÁËIE7.0,½ñÌìÈ´·¢ÏÖÇ°¼¸ÌìÓÃajax¿ª·¢µÄй¦Äܾ¹È»ÎÞ·¨Ê¹ÓÃ,¾¹ý±¾ÈËϬÀûµÄÄ¿¹â´ó·¶Î§µÄËÑË÷,ÖÕÓÚÕÒµ½Á˽â¾ö°ì·¨,ÔÒòÊÇIE7.0±ÈIE6.0¶àÁ˱¾µØXMLHTTPÖ§³Ö¡£ËùÒÔ½â¾ö·½·¨Ö®Ò»¾ÍÊǵã»÷¡°¹¤¾ß¡±->¡°InternetÑ¡Ï->¡°¸ß¼¶¡±£¬ÔÚ¡°°²È«¡±½ÚµãÏÂÕÒµ½¡°ÆôÓñ¾»úXMLHTTPÖ§³Ö¡±£¬¸ÃÑ¡ÏîĬÈÏÊǹ³Ñ¡£¬½ ......
±¾½Ì³Ì´´½¨Ê¹Óà ASP.NET µÄ AJAX ¹¦ÄܵĻù±¾Ê¾ÀýÓ¦ÓóÌÐò¡£Äú¿ÉÒÔÁ˽⵽ÓÐ¹Ø ASP.NET µÄ AJAX ¹¦Äܵĸü¶àÐÅÏ¢£¬½«ÖªµÀÕâЩ¹¦ÄÜÖ¼ÔÚ½â¾öÄÄЩ¼¼ÊõÎÊÌ⣬ÒÔ¼°ÒÔϽéÉÜÐÔÎĵµ½«Éæ¼°ÄÄЩÖØÒªµÄ AJAX ×é¼þ£º
·ASP.NET AJAX Overview
·Ìí¼Ó AJAX ºÍ¿Í»§¶Ë¹¦ÄÜ
ÔÚ±¾½Ì³ÌÖУ¬Äú½« ......