AJAXʵʱ¶ÁÈ¡ÊäÈëÎı¾
¿Í»§¶ËString.php,·þÎñÆ÷¶ËString_check.php£¬ºÜ¼òµ¥µÄʵÏÖ¡£
¿Í»§¶Ë´úÂ룺
<!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 sendRequest(){
createXMLHttpRequest();
var name = document.getElementById("name").value;
url = "String_check.php?page="+name;
xmlHttp.onreadystatechange = callback;
xmlHttp.open('GET',url,true);
xmlHttp.send(null);
}
function callback(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
document.getElementById("show").innerHTML = "ÄúÊäÈëµÄ×Ö·û´®Îª£º"+ xmlHttp.responseText;
}
}
}
</script>
<body>
<p>AJAX test;</p>
<p><br/>
<input type="text" id="name" onkeyup="sendRequest();" />
<br/>
<span id="show"></span>
</p>
</body>
</html>
·þÎñÆ÷¶Ë´úÂ룺
<?php
header('Content-type: text/html;charset=GB2312');
$ename = $_GET["page"];
if ($ename == "") {
$ename = "ÇëÊäÈ룺";
}
echo ($ename);
exit(0);
?>
Ïà¹ØÎĵµ£º
µ½Èí¼þ¹«Ë¾Ñ§IT¼¼Êõhttp://www.tsp2c.cn/
Ajax Ó¦¸Ã²»ÊÇÒ»Ïî¼¼Êõ£¬ÊÇÒ»ÖÖ˼Ïë¶øÒÑ£¬¸ú ASP.NET ÒÔ¼°ÆäËü Web ¿ª·¢ÓïÑÔûÓÐʲô̫´ó¹ØÏµ£¬ÕâÀïÖ»ÊÇ̸̸ ASP.NET ÖÐĿǰʹÓÃµÄ Ajax ¼¼ÊõÒÔ¼°ÆäËüһЩʵÏÖ Ajax µÄÓÅÐã¿ò¼Ü¡£
¡¡¡¡Ajax ÒѾºÜÁ÷ÐÐÒ»Õó×ÓÁË£¬ÏÖÔÚ̸ Ajax ¾õµÃÓеãÀÏÍÁ¡£Ä¿Ç°ËùνµÄ Web2.0 ÍøÕ¾£¬»ù±¾ÉÏûÓв» ......
Ajax±à³Ì Ajax»ùÓÚÒÔϼ¼Êõ£º DHTML, JavaScript, XmlHttpRequest£¬ JSON£¨JavaScript Object Notation£© ASP.NET 2.0 ÐèÒªÏÂÔØAJAX ¿âºÍ¿Ø¼þ£¬ ASP.NET 3.5°üº¬ÁËASP.NET AJAX¡£ & ......
Case I. Web´úÀíµÄ·½Ê½ (on Server A)
¼´Óû§·ÃÎÊAÍøÕ¾Ê±Ëù²úÉúµÄ¶ÔBÍøÕ¾µÄ¿çÓò·ÃÎÊÇëÇó¾ùÌá½»µ½AÍøÕ¾µÄÖ¸¶¨Ò³Ã棬ÓɸÃÒ³Ãæ´úÌæÓû§Ò³ÃæÍê³É½»»¥£¬´Ó¶ø·µ»ØºÏÊʵĽá¹û¡£´Ë·½°¸¿ÉÒÔ½â¾öÏÖ½×¶ÎËùÄܹ»Ïëµ½µÄ¶àÊý¿çÓò·ÃÎÊÎÊÌ⣬µ«ÒªÇóAÍøÕ¾ÌṩWeb´úÀíµÄÖ§³Ö£¬Òò´ËAÍøÕ¾ÓëBÍøÕ¾Ö®¼ä±ØÐëÊǽôÃÜÐ×÷µÄ£¬ÇÒÿ´Î½»»¥¹ý³Ì£¬AÍøÕ¾µÄ· ......
ѧϰAjax½Ì³Ì£¬ÏêϸÁ˽âGetÓëPost
Get·½Ê½:
×÷ÓÃ:¿É´«Ëͼòµ¥Êý¾Ý
´óС:url×î´ó³¤¶ÈÊÇ2083 bytes,¿ÉÒÔÓÃÓÚGET´«µÝÊý¾ÝµÄ³¤¶ÈÊÇ2048 bytes
°üº¬Ìå:Êý¾Ý×·¼Óµ½urlÖз¢ËÍ,Ò²¾ÍÊÇhttpµÄheader´«ËÍ
Post·½Ê½:
×÷ÓÃ:¿É´«Ëͼòµ¥¸´ÔÓÊý¾Ý
´óС:web.configÀïÏÞÖÆ
°üº¬Ìå:Êý¾ÝÔÚhttpÇëÇóµÄʵÌåÄÚÈÝÀï´«ËÍ
AjaxÓÃPostģʽ´«ËÍÊ ......