在使用者點擊提要列表條目時取得該提要的內容

來源:互聯網
上載者:User

在前一小節中可以看到,使用者每次點擊提要時均將調用readFeed()方法。因此我們即可在該readFeed ()方法中非同步呼叫伺服器端Web Service中的GetRssContent()方法,並將當前提要的ID傳遞過去。當然,在非同步呼叫之前同樣應該為使用者顯示出更新提示面板:

function readFeed(id) {
    // 顯示更新提示面板。
    showProgressBar(true);

    // 取得提要的內容。
    RssService.GetRssContent(id, onRssContentGot);
  }

調用GetRssContent()方法時提供的回調方法onRssContentGot()的代碼如下。其中先隱藏了更新提示面板,然後使用Web Service返回的ContentEntry[]資料構造出了提要的內容,並顯示到頁面右側的內容地區中:

function onRssContentGot(result) {
    // 隱藏更新提示面板。
    showProgressBar(false);

    // 構造提要內容HTML字串。
    var contentBuilder = new Sys.StringBuilder();
    for (var index = 0; index < result.length; ++index) {
      contentBuilder.append("<h3><a href="");
      contentBuilder.append(result[index].Link); // Link
      contentBuilder.append("" target="_blank" >");
      contentBuilder.append(result[index].Title); // Title
      contentBuilder.append("</a></h3><div>");
      contentBuilder.append(result[index].Content); //Content
      contentBuilder.append("</div><hr />");
    }

    // 設定到提要內容元素上。
    var content = $get("content");
    content.innerHTML = contentBuilder.toString();
  }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.