w3pop.com :: ÍøÂçѧԺ :: AJAX :: AJAX ·þÎñÆ÷¶Ë½Å±¾
AJAX ·þÎñÆ÷¶Ë½Å±¾
::
Now we are going to create the script that displays the current server time.
ÏÖÔÚ£¬ÎÒÃÇÒª×ÅÊÖ´´½¨ÓÃÓÚÏÔʾ·þÎñÆ÷µ±Ç°Ê±¼äµÄ½Å±¾³ÌÐò¡£
The responseText property (explained in the previous chapter) will store the data returned from the server. Here we want to send back the current time. The code in "time.asp" looks like this:
“responseText” ÊôÐÔ £¨ÔÚǰ¼¸ÕÂÀïÒѾ¶Ô¸ÃÊôÐÔ×÷ÁË˵Ã÷£©½«»á°Ñ·þÎñÆ÷¶Ë·µ»ØµÄÐÅÏ¢´¢´æÆðÀ´¡£ÔÚÕâÀÎÒÃÇÏ£Íû½«µ±Ç°Ê±¼ä·¢ËÍ»ØÈ¥¡£“time.asp” ÖеĴúÂëÈçÏÂËùʾ£º
<% |
Note: The Expires property sets how long (in minutes) a page will be cached on a browser before it expires. If a user returns to the same page before it expires, the cached version is displayed. Response.Expires=-1 indicates that the page will never be cached.
×¢Ò⣺Expires ÊôÐÔ½«ÉèÖÃÒ»ÕÅÒ³ÃæÔÚä¯ÀÀÆ÷ÖеĻº´æÊ±¼ä£¨µ¥Î»£º·ÖÖÓ£©¡£Èç¹ûÔڸûº´æµ½ÆÚʱ´ò¿ªÏàͬµÄÒ³Ãæ£¬ÄÇô½«»áÏÔʾ»º´æËù´æ´¢µÄÐÅÏ¢ÄÚÈÝ¡£Response.Expires=-1 ±íʾ²»¶ÔÒ³Ãæ½øÐлº´æ¡£
Try the AJAX application by typing some text into the Name text box below, then click inside the Time text box:
ÊÔ×ÅÔÚÏÂÃæµÄNameÎı¾¿òÄÚÊäÈëÐÅÏ¢£¬È»ºóµã»÷TimeÎı¾¿ò£¬²âÊÔÒ»ÏÂÕâ¸öAJAX³ÌÐò£º
The Time text box gets the server's time from "time.asp" file without reloading the page!
TimeÎı¾¿ò½«»áÏÔʾÀ´×ÔÓÚ“time.asp”ÎļþÖеÄʱ¼ä£¬ÎÞÐëÖØÐ¼ÓÔØÒ³Ãæ¡£
ÆÀÂÛ (0)
All