RSS reader Code implemented using jquery's Ajax Function

Source: Internet
Author: User

Let's take a look at the effect:

First, you need an ascx page to bind the content of the RSS source to a listview through an xdocument.CodeAs follows:

Copy code The Code is as follows: protected void page_load (Object sender, eventargs E)
{
// For demo purposes.
System. Threading. thread. Sleep (1000 );

Xdocument feedxml =
Xdocument. Load ("http://feeds.feedsky.com/csdn.net/dujingjing1230 ");

VaR feeds = from feed in feedxml. descendants ("item ")
Select New
{
Title = feed. element ("title"). value,
Link = feed. element ("Link"). value,
Description = feed. element ("Description"). Value
};

Postlist. datasource = feeds;
Postlist. databind ();
}

copy the Code the code is as follows:






  • <% # eval ("title") %>

    <% # eval ("Description ") %>


  • Create An ASPX page to display the RSS content. Of course, jquery Ajax is used on this page to obtain the above data.
    HTML page code:
    JS that implements Ajax: copy Code the code is as follows: $ (document ). ready (function () {
    $. ajax ({
    type: "Post",
    URL: "rssreader. asmx/getrssreader ",
    data:" {} ",
    contenttype:" application/JSON; charset = UTF-8 ",
    datatype:" JSON ",
    success: function (MSG) {
    $ ('# rsscontent '). removeclass ('loading');
    contents ('{rsscontent'{.html (MSG. d);
    }< BR >});
    });

    Finally, the content of rssreader. asmx Web Services is as follows:Copy codeThe Code is as follows: public class rssreader: system. Web. Services. WebService {
    [Webmethod]
    Public String getrssreader ()
    {
    Page page = new page ();
    Usercontrol CTL =
    (Usercontrol) page. loadcontrol ("~ /Rssreadercontrol. ascx ");
    Page. Controls. Add (CTL );
    Stringwriter writer = new stringwriter ();
    Httpcontext. Current. server. Execute (page, writer, false );
    Return writer. tostring ();
    }
    }

    The page also uses an image and will not be uploaded here.
    Download Code:
    Http://xiazai.jb51.net/200909/yuanma/RSSREader.rar

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.