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Éæ¼°µ½JAVASCRIPT¼¼Êõ£¬ËùÒÔ»¹ÊÇÃæ¶Ô¿çä¯ÀÀÆ÷µÄ·³ÈÅ¡£ajaxÔÚÒ³ÃæÉÏ´¦ÀíһЩ¼òµ¥Â߼ʱ£¬ÐèÒªÓÃJAVASCRIPTÀ´´¦Àí£¬Äã°²ÐĵÄÔÚÄãµÄä¯ÀÀÆ÷ÉϱàÒë½âÎöͨ¹ýÁË£¬ÄãÒÔΪ´ó¹¦¸ã³ÉÁË£¬¿ÉÊÇÊâ²»Öª£¬½Óõà¶øÀ´µÄÊÇ¿Í»§µÄͶËߣ¬ÒòΪÄãÔÒÔΪ³É¹¦µÄÒ³ÃæÔÚËûà ......
<mce:script language=javascript><!--
//×¢²áÃüÃû¿Õ¼ä
Type.registerNamespace("Demo");
Demo.Message=function(content,publishTime)
{
this._content = content;
this._publishTime = publishTime;
}
Dem ......
Ajax±à³Ì Ajax»ùÓÚÒÔϼ¼Êõ£º DHTML, JavaScript, XmlHttpRequest£¬ JSON£¨JavaScript Object Notation£© ASP.NET 2.0 ÐèÒªÏÂÔØAJAX ¿âºÍ¿Ø¼þ£¬ ASP.NET 3.5°üº¬ÁËASP.NET AJAX¡£ & ......
AJAXʵÏÖ¶þ¼¶¼¶Áª²Ëµ¥£¬ÓÃ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 ......
ǰ̨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>
<title>ÎÞ±êÌâÒ³</title>
<style ......