AJAX¶¯Ì¬»ñÈ¡µ±Ç°Ê±¼ä
ÀûÓÃAJAX¶¯Ì¬»ñÈ¡µ±Ç°Ê±¼ä£¬¿Í»§¶Ëtime.php,·þÎñÆ÷¶Ëtime_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();
}
else{
alert("´´½¨ÇëÇóʧ°Ü");
}
}
function sendRequest(){
createXMLHttpRequest();
url = "time_check.php";
xmlHttp.onreadystatechange = callback;
xmlHttp.open('GET',url,true);
xmlHttp.send(null);
}
function callback(){
if(xmlHttp.readyState ==4){
if(xmlHttp.status == 200){
document.getElementById("time").innerHTML = xmlHttp.responseText;
setTimeout("sendRequest()",1000);
}
}
}
</script>
<body>
<input type="button" value="check it" onclick="sendRequest();" />
<br/>
<span id="time"></span>
</body>
</html>
·þÎñÆ÷¶Ë´úÂ룺
<?php
header("cache-control:no-cache,must-revalidate"); //È¡ÏûphpÒ³Ã滺´æµÄÉèÖÃ
header('Content-type: text/html;charset=GB2312');
$showtime = date("±±¾©Ê±¼äYÄêmÔÂdÈÕH:i:s");
echo $showtime;
?>
Ïà¹ØÎĵµ£º
FlexÓëAjax½»»¥
ÈýÏ¿´óѧÍÁľˮµçѧԺФÔóÔÆ
FlexÓëAjax¶¼ÊÇ¿ª·¢AIR·Ç³£ºÃµÄ¼¼Êõ£¬ËüÃǸ÷ÓÐÓÅȱµã¡£Flex¸ü¼òµ¥£¬Ð§¹û¸ü¼Ó¿á£¡µ«ÊÇÔÚ¹¦ÄÜ¿ª·¢µÈ·½Ãæ²»¼°Ajax³ÉÊì¡£×îÀíÏëµÄ¾ÍÊÇÈ«²¿ÓÃFlexÀ´¿ª·¢ÊµÏÖ£¬µ«ÕâÖ»ÊÇÒ»ÖÖÀíÏë״̬£¬ºÜ¶àʱºòÎÒÃÇ»¹ÊÇÒªÓõ½Ajax¡£ÎÒÃǾ³£ÐèÒª½«Ç¶Èëµ½ Ajax Ó¦ÓóÌÐòÖеĻùÓÚ Flash µÄ×ÊÔ´¼¯³ÉÔÚÒ» ......
XMLHttpRequestÊÇXMLHTTP×é¼þµÄ¶ÔÏó£¬Í¨¹ýÕâ¸ö¶ÔÏó£¬Ajax¿ÉÒÔÏñ×ÀÃæÓ¦ÓóÌÐòÒ»Ñùֻͬ·þÎñÆ÷½øÐÐÊý¾Ý²ãµÄÐÅÏ¢½»»»£¬¶ø²»ÓÃÿ´Î¶¼Ë¢ÐÂÒ³Ã棬Ҳ²»ÓÃÿ´Î½«Êý¾Ý´¦ÀíµÄ¹¤×÷¶¼½»¸ø·þÎñÆ÷À´×ö£»ÕâÑù¼´¼õÇáÁË·þÎñÆ÷µÄ¸ºµ£ÓÖ¼Ó¿ìÁËÏìÓ¦Ëٶȡ¢Ëõ¶ÌÁËÓû§µÈ´ýµÄʱ¼ä¡£
XMLHttpRequestÊÇAjax¼¼ÊõÖÐ×î ......
PHP 5.2 ¼°ÒÔÉÏ°æ±¾ÌṩÁË json_encode ºÍ json_decode º¯Êý£¬Ï൱ºÃÓá£
¶ø֮ǰµÄ°æ±¾ÔòÐèÒªÏÂÔØÍøÓÑÃÇ×ÔÐпª·¢µÄ¿â£¨ÓÐÐËȤµÄ¿ÉÒÔ¿´Ï http://code.itlearner.com/php/JSON-class.html £©
¿ÉÒԲο¼ÈçÏÂÕâ¸ö·½·¨À´ÔڵͰ汾ÉÏÀ©³äÕâÁ½¸öº¯Êý£º
if (!function_exists('json_encode') && !function_exists('j ......
ѧϰAjax½Ì³Ì£¬ÏêϸÁ˽âGetÓëPost
Get·½Ê½:
×÷ÓÃ:¿É´«Ëͼòµ¥Êý¾Ý
´óС:url×î´ó³¤¶ÈÊÇ2083 bytes,¿ÉÒÔÓÃÓÚGET´«µÝÊý¾ÝµÄ³¤¶ÈÊÇ2048 bytes
°üº¬Ìå:Êý¾Ý×·¼Óµ½urlÖз¢ËÍ,Ò²¾ÍÊÇhttpµÄheader´«ËÍ
Post·½Ê½:
×÷ÓÃ:¿É´«Ëͼòµ¥¸´ÔÓÊý¾Ý
´óС:web.configÀïÏÞÖÆ
°üº¬Ìå:Êý¾ÝÔÚhttpÇëÇóµÄʵÌåÄÚÈÝÀï´«ËÍ
AjaxÓÃPostģʽ´«ËÍÊ ......