Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

jQuery AJAXµÄ5ÖÖʵÏÖ·½Ê½

What is AJAX
This section is for those who have no idea what AJAX is. If you don’t fall into this category, feel free to skip to the next section.
AJAX stands for asynchronous JavaScript and XML. If you see another term XHR, which is shorthand for XML HTTP request, it’s the same thing. Don’t be afraid of this jargon; AJAX is not rocket science.
In Gmail, switch from inbox to draft. Part of the page is changed, but the page is not refreshed. You remain on the same page. Url has not changed (except for the #draft at the end of the url, but that’s still the same webpage).
In Google Reader, select a feed. The content changes, but you are not redirected to another url.
In Google Maps, zoom in or zoom out. The map has changed, but you remain on the same page.
The key to AJAX’s concept is “asynchronous”. This means something happens to the page after it’s loaded. Traditionally, when a page is loaded, the content remains the same until the user leaves the page. With AJAX, JavaScript grabs new content from the server and makes changes to the current page. This all happena within the lifetime of the page, no refresh or redirection is needed.
Caching AJAX
Now we should know what AJAX actually is. And we know that, when Gmail refreshes some content without redirection, an AJAX call is made behind the scenes. The requested content can either be static (remains exactly the same all the time, such as a contact form or a picture) or dynamic (requests to the same url get different responses, such as Gmail’s inbox where new mails may show up any time).
For static content, we may want the response cached. But for dynamic content, which can change in a second’s time, caching AJAX becomes a bug, right? It should be noted that Internet Explorer always caches AJAX calls, while other browsers behave differently. So we’d better tell the browser explicitly whether or not AJAX should be cached. With jQuery, we can


Ïà¹ØÎĵµ£º

¡¾¾ÉÎÄ¡¿AJAX×ܽᣨһ£©

AJAX¼ò½é
Ò»¡¢AJAXÊÇʲô
ÔÚ´«Í³µÄwebÓ¦ÓÃÖУ¬Óû§ÓëÓ¦ÓõÄÿһ´Î½»»¥£¬¶¼ÊÇÊ×ÏÈÓû§Í¨¹ýä¯ÀÀÆ÷Ïò·þÎñÆ÷¶Ë·¢ËÍÒ»¸ö
ÇëÇ󣬷þÎñÆ÷½âÎöÕâ¸öÇëÇ󣬽«ÏàÓ¦µÄÏìÓ¦ÐÅÏ¢·µ»Ø¸øä¯ÀÀÆ÷¡£ÔÚ·þÎñÆ÷¶ËÒµÎñÂß¼­·Ç³£¸´ÔÓ»òÕßÐèÒªºÄʱ½Ï³¤µÄÇé¿öÏ£¬ä¯ÀÀÆ÷µÈ´ýË¢ÐÂʱ£¬Ò³Ãæ¾­³£ÊÇһƬ¿Õ
°×£¬Óû§Ö»Äܱ»¶¯µÈ´ý·þÎñÆ÷¶ËÏìÓ¦Íê³É£¬ÔÚ´ËÆÚ¼ ......

¡¾¾ÉÎÄ¡¿AJAX×ܽᣨ¶þ£©

ËÄ¡¢DOM
1.DOM¸ÅÊö
XHR¶ÔÏóÌṩÁ˸ú·þÎñÆ÷ͨѶµÄÄÜÁ¦£¬¶øDOMÌṩÁË·ÃÎÊ¡¢¶¯Ì¬¸üÐÂÒ³ÃæµÄÄÜÁ¦¡£
DOMÊÇW3CÍƳöµÄÎĵµ¶ÔÏóÄ£ÐÍ£¬ÊDZíʾÎĵµºÍ·ÃÎÊ¡¢²Ù×÷¹¹³ÉÎĵµµÄ¸÷ÖÖÔªËصÄAPI£¬±»¶¨ÒåΪ¶ÀÁ¢ÓÚÓïÑԵıê×¼£¬ÔÚjavascriptºÍjavaÒÔ¼°ÆäËûÓïÑÔÖж¼ÓÐʵÏÖ¡£
ÔÚDOMÖУ¬HTMLÎĵµµÄ²ã´Î»ú¹¹±»±íʾΪÊ÷Ðνṹ£¬Ê÷µÄ½Úµã±íʾÎĵµÖÐ ......

SyntaxHighlighterÓëajaxÁªºÏʹÓÃÓöµ½µÄÎÊÌâ

SyntaxHighlighterÊÇÒ»¸ö´úÂë¸ßÁÁ²å¼þ£¬cnblogsµÄÆÀÂÛÒ²Óõ½ÁËSyntaxHighlighter¡£SyntaxHighlighterµÄÏêϸ½éÉÜ£¬Ô°×ÓÖÐÓкܶࡣÕâÀï¾Í²»½éÉÜÁË¡£
ʹÓÃJQµÄAjax
˵ÏÂÎÒÓöµ½µÄÎÊÌ⣬ÏÂÃæÊDzâÊÔÒ³Ã棺
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></ ......

¹ØÓÚAjaxµÄÒì²½»úÖÆ


Ajax(Asynchronous JavaScript and XML)ÊÇÒ»¸ö½áºÏÁËJava¼¼Êõ¡¢XML¡¢ÒÔ¼°JavaScriptµÄ±à³Ì¼¼Êõ£¬¿ÉÒÔÈÃÄã¹¹½¨»ùÓÚJava¼¼ÊõµÄWebÓ¦Ó㬲¢´òÆÆÁËʹÓÃÒ³ÃæÖØÔصĹßÀý¡£
Ajax£¬Òì²½JavaScriptÓëXML£¬ÊÇʹÓÿͻ§¶Ë½Å±¾ÓëWeb·þÎñÆ÷½»»»Êý¾ÝµÄWebÓ¦Óÿª·¢·½·¨¡£ÕâÑù£¬WebÒ³Ãæ²»Óôò¶Ï½»»¥Á÷³Ì½øÐÐÖØмӲ㬾ͿÉÒÔ¶¯Ì¬µØ¸üС£Ê ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ