Using jQuery to parse RSS feeds having firefox and chrome issues

I used a jQuery library called jFeed to parse and display my rss feed on my personal website. It worked fine at first, but after checking it just doesn't display anything except Internet Explorer, where it works fine.

After checking the javascript console using Firebug in Firefox, an error is displayed on the XML tab:

XML parsing error: element not found. Location: moz-nullprincipal: {3f8a0c62-32b4-4f63-b69c- 9ef402b40b64} Row number 1, column 1: ^

Although I have no idea what to do with this information. Here is the code I used to get the rss feed and display it (it's almost the same as the example provided by the jFeed website):

jQuery.getFeed ({url: ' http://sammarshalldesign.co.uk/blog/wordpress/?feed=rss2 ', success: function (feed) {

        var html = '';

        for(var i = 0; i < feed.items.length && i < 5; i++) {

            var item = feed.items[i];

            html += '<h3>'
            + '<a href="'
            + item.link
            + '">'
            + item.title
            + '</a>'
            + '</h3>';


            html += '<div>'
            + item.description
            + '</div>';
        }//end for

        jQuery('#feed').append(html);
    }//end feed function    
});//end getfeed

Any help would be really appreciated.

+3
source share
3 answers

Alternatively, Google provides feed api . Check out the Google Feed plugin , which makes the whole process pretty simple (no php required).

+1
source

Are you trying to download an RSS feed from another domain? If so, it will not work. jFeed comes with a sample PHP proxy that you can host on your server and call. Or you can use Yahoo! Pipes to receive data in JSON format.

0

I found this to be difficult, but, unlike Internet Explorer, Firefox does not allow cross-domain XML requests without any authentication from the server you click on. You need to either use JSON (which you can execute using a cross-site / cross-domain query in jQuery) or create some kind of proxy server for your XML feed locally, and then hit it with your jQuery query.

0
source

Source: https://habr.com/ru/post/1736894/


All Articles