ajaxÖÆ×÷±íµ¥Ñé֤ʾÀý
ajaxµÄ¹¦ÄÜÖ÷ÒªÊÇÓ¦ÓÃÔÚjsÉÏ£¬ajax¶ÔaspûʲôҪÇó£¬aspÖ»¸ºÔðÔÚºǫ́ÏÔʾ¼°²Ù×÷·þÎñ¶ËµÄÊý¾Ý¡£
¿ÉÒÔÏñÏÂÃæÕâÑù˼¿¼£º
1.д±íµ¥µÚÒ»ÏÈçÓû§Ãû£©
2.onblurʼþ(ʧȥ½¹µã)·¢Éúʱ¿ªÊ¼ÑéÖ¤£¬onblur="checkusername()"
3.js·¢Ò»¸öÇëÇó¸øµÚÒ»¸öasp(¼Ù¶¨Îªajaxusername.asp)Èç¹û´ÓÊý¾Ý¿âÖÐÕÒµ½ÁËÕâ¸öÓû§£¬¸ø³ö1(ajaxusername.aspËù
ÓÐÄÚÈݾÍÊÇÒ»¸ö1)Èç
<%
if(user.exist())response.write "1"
%>
4.jsÊÕµ½£¬»á×Ô¶¯Ö´ÐÐcheckuser()º¯Êý¡£
checkuser°ÑÓû§ÃûÒ»Ðе×É«¸Ä±ä£¬²¢ÏÔʾ“Óû§¼º´æÔÚ”
asp²¿·ÖÄã¾Í×Ô¼ºÐ´ÁË¡£ÏÂÃæ¸ø³öһЩjs´úÂë¡£
<script>
/*ÒÔϺ¯ÊýÒ»°ã²»ÐèÒª¸Ä±ä*/
var Ajax;
function CreateAjax(){
if (window.XMLHttpRequest){
Ajax = new XMLHttpRequest();
}else if (window.ActiveXObject){
Ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function SendData(url_,sendtext_){
Ajax.open("POST",url_,true);
Ajax.onreadystatechange = checkuser;
Ajax.send(sendtext_);
}
function CheckAjaxStatus(Ajax_){
if(Ajax_.readyState == 4)
if(Ajax_.status == 200)
return true;
return false;
}
/*ÒÔÉϺ¯ÊýÒ»°ã²»ÐèÒª¸Ä±ä*/
function checkuser(){
if(!CheckAjaxStatus(Ajax))return;
//asp·µ»Ø¹û¶Ô½á¹ûµÄ´¦Àí¡£·þÎñÆ÷·µ»ØµÄ¾ÍÊÇajaxusername.asp£¬Õâ¸ö½á¹û´æÓÚAjax.responseTextÊôÐÔÖС£
}
function checkusername(){
CreateAjax();
SendData("ajaxusername.jsp","username=" + name);
}
</script>
Ïà¹ØÎĵµ£º
Web¿ª·¢Õß²»»á×¢Òâµ½ÓÉ “AJAX(Asynchronous JavaScript And
XML)”Ëù´øÀ´µÄ¼¤Çé¡£²»·ÑÁ¦Æø¾ÍÄÜ´´½¨ÏñGoogle
SuggestÄÇÑùµÄÖÇÄÜÍøÕ¾»òÕßÏñGmailÄÇÑù»ùÓÚWebµÄÓ¦ÓóÌÐò£¬ÕâÔںܴó³Ì¶ÈÉÏÒª¹é¹¦ÓÚÕâÖÖ¼¼Êõ¡£È»¶ø£¬°éËæ×ÅAJAXÓ¦ÓóÌÐòµÄ·¢Õ¹£¬ÎÒÃÇ·¢
ÏÖÁËËüµÄһЩ²»×ãÖ®´¦£¬ÎÒÃÇ·¢ÏÖËüµÄ°²È«Â©¶´Ò²ÔÚÖð½¥±ä´ó£¬¾ÍÏ ......
xmlHttpÐÎʽµÄAjax£ºXmlHttpÐÎʽµÄAjax IBM¼¼ÊõÎĵµ¿â
ÒÔÏÂÊÇÀûÓÃÒþ²ØiframeʵÏÖµÄajax:
index.htm
<html>
<head>
</head>
<body>
<iframe id="testFrame" frameborder="0" style="width:0px; height:0px;">
</ifra ......
jQuery ÊÇÒ»¸öJavaScript ¿â£¬ËüÓÐÖúÓÚ¼ò»¯ JavaScript™ ÒÔ¼° Asynchronous JavaScript + XML (Ajax) ±à³Ì¡£ÓëÀàËÆµÄ JavaScript ¿â²»Í¬£¬jQuery ¾ßÓжÀÌصĻù±¾ÔÀí£¬¿ÉÒÔ¼ò½àµØ±íʾ³£¼ûµÄ¸´ÔÓ´úÂ롣ѧϰ jQuery »ù±¾ÔÀí£¬Ì½Ë÷ÆäÌØÐԺ͹¦ÄÜ£¬Ö´ÐÐһЩ³£¼ûµÄ Ajax ÈÎÎñ²¢ÕÆÎÕÈçºÎʹÓòå¼þÀ©Õ¹ jQuery¡£
jQuery ÊÇʲ ......