0

I've been trying to make atom feed work using jQueryMobile since last night but no luck. I am working the code locally.

I am using this scripts provided in jQueryMobile site

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>

I tried a lot of code and I end up using the code answered in this question Parse RSS with jQuery

this is my code

function refreshFeed2() {
    $.get("resp2.xml", function (data) { 
        var $xml = $(data);
        $xml.find("item").each(function () {
            var $this = $(this),
            item = {
                title: $this.find("title").text(),
                link: $this.find("link").text(),
                description: $this.find("description").text(),
                pubDate: $this.find("pubDate").text(),
                author: $this.find("author").text()
            }
            alert(item.title);
        });
    });
}

at the end, I tried popping up an alert but it's not showing anything.

what's wrong in the code?

--- update --- I am working with mobile devices --- update ---
for the sake debugging. here's an updated code

function refreshFeed2() {
    alert("start call");

    $.get("resp.xml", function (data) {
        alert("start parse");

        var $xml = $(data);

        alert("set data");

        $xml.find("item").each(function () {
            var $this = $(this),
            item = {
                title: $this.find("title").text(),
                link: $this.find("link").text(),
                description: $this.find("description").text(),
                pubDate: $this.find("pubDate").text(),
                author: $this.find("author").text()
            }
            alert(item.title);
        });
    });

    alert("end call");
}

so I added alerts .. the problem there is it only popups in "start call" and "end call".
My sample xml looks like this.. but this is actually a lot longer

<rss    version="2.0" 
        xmlns:content="http://purl.org/rss/1.0/modules/content/" 
        xmlns:wfw="http://wellformedweb.org/CommentAPI/" 
        xmlns:dc="http://purl.org/dc/elements/1.1/" 
        xmlns:atom="http://www.w3.org/2005/Atom" 
        xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 
        xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
    <channel>
        <title>title of the feed</title>
        <atom:link href="http://www.mainlink.com/livefeed" rel="self" />
        <link>http://www.mainlink.com/</link>
        <description>
        </description>
        <language>en-us</language>
        <pubDate>Fri, 06 Jul 2012 04:47:51 +0800</pubDate>
        <lastBuildDate>Fri, 06 Jul 2012 04:47:51 +0800</lastBuildDate>
        <item>
            <title>title1</title>
            <link>http://www.link1.com/</link>
            <description>desc1</description>
            <pubDate>Fri, 06 Jul 2012 04:47:09 +0800</pubDate>
            <guid>25542832</guid>
        </item>
        <item>
            <title>title2</title>
            <link>http://www.link1.com/</link>
            <description>desc2</description>
            <pubDate>Fri, 06 Jul 2012 04:47:09 +0800</pubDate>
            <guid>25542831</guid>
        </item>
    </channel>
</rss>
Community
  • 1
  • 1
Jayson Ragasa
  • 1,011
  • 4
  • 19
  • 33

1 Answers1

1

Drop a breakpoint in there and step through the code execution. If your alert isn't showing that means either 1) the $.get request failed so your 'success' function will never get called or 2) your success function is getting called but it doesn't get to the alert because one of the find or text calls throws an exception.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Robert Levy
  • 28,747
  • 6
  • 62
  • 94
  • fantastic. you'll still have to drop in a breakpoint and step through the code execution to find out which of the two possible problems I mentioned is occuring. we can't tell you, for example, whether "resp2.xml" is the correct url for your file or whether your server is properly configured to return that file – Robert Levy Jul 06 '12 at 03:17
  • it worked in my website http://www.jaysonragasa.net/files/test/index.html but not locally.. anyway.. – Jayson Ragasa Jul 06 '12 at 03:27
  • since I want to run this locally because I am running PhoneGap for windows phone and therefore, the xml has to be a local file.. interestingly, it worked on IE, but not in Chrome – Jayson Ragasa Jul 06 '12 at 03:31