AJAXÑéÖ¤Óû§Î¨Ò»ÐÔ
´ÓÊý¾Ý¿âmyÖеÄusernameÓû§±íÀïÑéÖ¤£º
checkusername.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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ</title>
</head>
<script language="javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function send_request(url,data){
createXMLHttpRequest();
xmlHttp.open("POST",url,true);
xmlHttp.onreadystatechange = check_lll;
xmlHttp.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded");
xmlHttp.send("username=" + data);
}
function check_lll(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
alert(xmlHttp.responseText);
}
}
}
function check_username(){
var f = document.form1;
var username = f.username.value;
if(username == ""){
alert("NULL");
return false;
}
else{
send_request("check_it.php",username);
}
}
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<p> </p><p>
ÐÕÃû£º <input type="text" name="username" />
</p>
<input type="button" value="check it" onclick="check_username()" />
<p> </p>
<p> </p>
</form>
</body>
</html>
check_it.php£º
<?php
$username = $_POST["username"];
$conn = mysql_connect("localhost:3306","root","123");
mysql_select_db("my",$conn);
$sql = "select * from username where userna
Ïà¹ØÎĵµ£º
AJAX(Asynchronous JavaScript and XML):»ùÓÚXMLµÄÒì²½JavaScript£¬¼ò³ÆAJAX,ÊǶàÖÖ¼¼ÊõµÄ×ÛºÏ.
Ò»ÖÖ¿Í»§¶Ë¼¼Êõ ,Ϊ»¥ÁªÍøÓû§Ìṩ¸ü¼ÓÓÑÉÆµÄ½»»¥½çÃæ,¸ü¼ÓÁ÷³©µÄÓû§ÌåÑé.Ò²¾ÍÊÇËùνµÄÅÖ¿Í»§¶Ë,Ê¹ÍøÒ³µÄЧ¹ûÄܹ»Ïñ°²×°ÔÚ¼ÆËã»úÉϵÄÓ¦ÓÃÈí¼þ»òϵͳһÑùÓѺûªÀö.
ËüÓÉÈçÏÂËÄÖÖ¼¼Êõ×é³É:CSS + DOM + XMLHttpRe ......
ICallbackEventHandler
aspx Ò³Ãæ£º
function CallServer(PhotoId)
{
document.getElementById("updatediv").style.display = "block";
documen ......
½ñÌìС±àºÍ´ó¼Ò·ÖÏíµÄÊÇJSON²å¼þʵÏÖAjax£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
1£¬JSON»ù´¡ÖªÊ¶
JSON²å¼þÊÇStruts2µÄAjax²å¼þ£¬Í¨¹ýÀûÓÃJSON²å¼þ£¬ÔÊÐí¿ª·¢ÕßÒԷdz£Áé»î¼òµ¥µÄ·½Ê½À´¿ª·¢AjaxÓ¦Óá£
JSONµÄÈ«³ÆÊÇJavaSrcipt Object Notation,¼´JavaScript¶ÔÏó·ûºÅ,ËüÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»¸ñʽ.JSONµÄÊý¾Ý¸ñʽ¼ÈÊʺÏÈ ......
±³¾°ÃèÊö£º
ÓÐÒ»¸ö±íµ¥£¬ÀïÃæÓÐÐÕÃû£¬êdzƣ¬µç»°µÈÐÅÏ¢£¬È»ºóÌá½»µÄʱºòÒª½øÐÐһЩÅжϣ¬±ÈÈçÊDz»ÊÇûÓÐÌîд£¬µç»°ºÅÂëÊÇ·ñ·ûºÏ¹æÔòµÈµÈ£¬Åжϲ»Í¨¹ýµÄ»°£¬Ôò×èÖ¹Ìá
½»¡£»¹ÓÐÒ»ÏîÐèÇóÊÇÅжÏêdzÆÊÇ·ñº¬ÓÐϵͳҪ¹ýÂ˵Ĵʻ㣬¶øÕâЩ´Ê»ãµÄÁÐ±í´æ·ÅÔÚ·þÎñÆ÷ÉÏ£¬ËùÒÔÐèÒªÓõ½ajaxÀ´×ö¡£
&nbs ......