kukooBlog

          look to the master, follow the master, walk with the master, see through the master, become the master.

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            213 隨筆 :: 0 文章 :: 285 評論 :: 0 Trackbacks
          <2005年5月>
          24252627282930
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          常用鏈接

          隨筆分類(250)

          隨筆檔案(213)

          最新評論

          閱讀排行榜

          評論排行榜

          首先讓我們先知道一下什么是AJAX(注意這不是荷蘭的甲級足球俱樂部阿甲克斯)。AJAX的全稱是: Asynchronous JavaScript And XML。

          JavaRSS.com是一個關于Java新聞的聚合站點,收錄了幾乎全部的關于Java的網站的新聞,比如TheServerside。這些新聞,除了標題之外,還有一些簡單的說明,如果把這些說明一次性的顯示在首頁上,那么時間估計會相當長(因為首頁顯示了大約600條新聞)。JavaRSS.com在首頁上就采用了AJAX技術,通過Lazy Loading來處理:即只有當用戶把鼠標移到這個新聞標題上的時候,才會顯示這個簡單的說明。

          JavaRSS.com在他自己的網站上公布了使用AJAX的細節。它的關鍵部分就是以下的代碼:

           1function getDescription(channelId,itemId) {     
           2   var url = 'http://localhost:8080/getDescription.jsp?channelId=' + channelId + '&itemId=' + itemId;     
           3   if (window.XMLHttpRequest) {         
           4      req = new XMLHttpRequest();     
           5   } else if (window.ActiveXObject) {         
           6      req = new ActiveXObject("Microsoft.XMLHTTP");     
           7   }     
           8   req.onreadystatechange = processRequest;     
           9   req.open("GET", url, true);     
          10   req.send(null); 
          11
          12
          13function processRequest() {     
          14   if (req.readyState == 4) {         
          15      if (req.status == 200) {           
          16         parseMessages();         
          17      } else {           
          18         alert ( "Not able to retrieve description" );         
          19      }     
          20   } 
          21
          22
          23function parseMessages() {         
          24   response = req.responseXML.documentElement;         
          25   itemDescription = response.getElementsByTagName('description')[0].firstChild.data;         
          26   alert ( itemDescription ); 
          27}


          TheServerside上面post了一條評論“AJAX In Action on JavaRSS”,有興趣的可以看看。其實,Google Map, Gmail 都在使用AJAX。

          posted on 2005-05-17 15:54 kukooBlog 閱讀(502) 評論(0)  編輯  收藏 所屬分類: Others
          主站蜘蛛池模板: 桐乡市| 库尔勒市| 衡阳市| 绵阳市| 乐陵市| 县级市| 新津县| 楚雄市| 平乡县| 明溪县| 双牌县| 汝城县| 会泽县| 隆德县| 盈江县| 青龙| 五寨县| 高尔夫| 阿城市| 方山县| 武功县| 邵东县| 多伦县| 白河县| 大冶市| 金乡县| 静乐县| 姚安县| 方正县| 江永县| 沙田区| 灌云县| 加查县| 邢台市| 凤山县| 岗巴县| 武定县| 临潭县| 柳林县| 永吉县| 商丘市|