ajax³¬Ê±ÎÊÌâ
var xmlHttp = null;
function Getxmlhttp()
{
var url = "update.php";
if (xmlHttp == null)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("ÄúµÄä¯ÀÀÆ÷²»Ö§³ÖAJAX£¡ÇëÉý¼¶ä¯ÀÀÆ÷°æ±¾!");
return;
}
}
//alert("Object Build Ok");
xmlHttp.onreadystatechange = xmlstatechange;
xmlHttp.open("GET",url,true);
xmlHttp.send();
window.setTimeout("Getxmlhttp()",5000);
}
ÎÒÔÚGetxmlhttpÖÐÉèÖÃÁ˶¨Ê±5ÃëÖ´ÐÐÒ»´Îgetxmlhttp£¬update.phpÀï¶ÔÊý¾Ý¿â½øÐвÙ×÷£¬Éú³É±í¸ñʵÏÖ×Ô¶¯Ë¢ÐµĹ¦ÄÜ
³ÌÐòÄܹ»ÔËÐУ¬¶øÇÒÒ²Äܹ»ÊµÏÖ×Ô¶¯Ë¢Ð£¬µ«ÊDz»ÖªµÀΪʲôÔËÐÐÒ»¶Îʱ¼äÖ®ºó¾Í²»ÄÜÕý³£µÄ»ñÈ¡µ½update.phpÀïÃæµÄÊý¾ÝÁË¡£²»ÖªµÀ´ó¼ÒÓÐûÓÐÓöµ½¹ýÕâÖÖÇé¿ö?
·À»º´æ°É¡£¡£¡£¡£
var url = "update.php?sid"+Math.random();
»òÕß¼ÓÈëʱ¼ä
¼ÓÈëʱ¼äÊÇÖ¸³¬Ê±µÄʱ¼äÂ𣿷À»º´æÊÇʲôһ¸ö¸ÅÄ¶àл
Äãÿһ´ÎÌá½»µÄµØÖ·¶¼ÊÇͬһµØÖ·
±ÈÈçÄãµÚÒ»´ÎÌá½» a.asp
¶øÄãÏ£Íûasp Êä³ö aaa Öµ£¬aspÊä³öÁË aaa µÄÖµ£¬Ò²ÊǶԵġ£
ÄãµÚ¶þ´ÎÌá½»µ½ a.asp
¶øÄãÏ£Íû aspÊä³ö bbb Öµ£¬µ«asp¿ÉÄÜ»¹ÊÇÊä³ö aaa Öµ£¬×îºÃ·½·¨¾ÍÊǵØÖ·ºó¼ÓÉÏÒ»¸ö²»Í¬µÄ±äÁ¿£¬µ«µÃÿ´ÎÌá½»µØÖ·Ò»Ñù£¬µ«url²»Í¬¡£ÒÔ·À»º´æ¡£
ÊÔÁËһϣ¬ºÃÏó²»ÊÇÕâ¸ö»º´æµÄÎÊÌâ£
Ïà¹ØÎÊ´ð£º
JScript code:
<script language="javascript">
var target = null;
function createTarget(){
if(window.ActiveXObject){
target = new ActiveXObject(" ......
ÏÖÔÚÓÐÁ½¸öÒ³ÃæAºÍB£º
ÔÚAÒ³ÃæÓÐÒ»¸öÁ´½Ó£¬ÊÇB.aspx#commentµÄÐÎʽ
Ò²¾ÍÊǶ¨Î»BÒ³ÃæµÄêµã£¬¶øÇÒBÒ³ÃæµÄÄÚÈÝÊÇAJAX¼ÓÔصģ¬
µ±¼ÓÔØÍê³ÉºóÎÞ·¨×¼È·¶¨Î»µ½Ãªµã£¬
¹À¼ÆÊÇÒ»´ò¿ªBÒ³ÃæʱҳÃæ ......
Java code:
<!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.o ......
×î½üѧϰAJAX,²ÎÕÕhttp://dev.yesky.com/msdn/183/2426683.shtml×Ô¼º×öÁËÒ»¸öÁÐ×Ó£¬µ«ÊÇ×ÜÊÇÔÚJS´¦±¨´í_Default䶨Ò壬²»ÖªµÀʲôÔÒò¡£
ǰ̨ҳÃ棺
function comit_onclick()
{
¡¡var name=document. ......
֮ǰÓöµ½Ò»¸öÎÊÌâ¡£
ÓÚÊÇ×öÁËÒÔÏÂʵÑ飺
Ò³Ãæ¼ÓÔغó£¬Ìá½»Ò»¸öAjaxÇëÇó(ÔݳÆΪajax1)£¬ÇëÇóµÄÏß³ÌÔÚ·þÎñÆ÷Éϱ»Ë¯Ãß10ÃëÖÓ¡£
µã»÷Ò³ÃæÉÏÒ»¸öbutton£¬´¥·¢ÁíÒ»¸öAjaxÇëÇó(ajax2)¡£
µ±Ã»ÓÐʹÓÃsession£¬ÔÚ·þÎñÆ÷δ´ ......