Problems reading an RSS feed using jQuery.get ()

I am pulling my hair out trying to use jQuery.get () to pull out a dynamically generated RSS feed and I have nothing but problems, is my RSS feed the wrong format? If so, can I convert it to the correct format using javascript?

Here is my channel: http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id=0

Here is my code:

function get_rss_feed() {

        $(".content").empty();

        $.get("http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id=0", function(d) {

            var i = 0;
            $(d).find('item').each(function() {

                var $item = $(this);
                var title = $item.find('title').text();
                var link = $item.find('link').text();
                var location = $item.find('location').text();
                var pubDate = $item.find('pubDate').text();

                var html = '<div class="entry"><a href="' + link + '" target="_blank">' + title + '</a></div>';

                $('.content').append(html);
                i++;
            });

        });
};

Any input would be greatly appreciated !! Thanks

+3
source share
3 answers

I tried this in IE and it worked fine.


$(document).ready(function() {
            $.get('http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id=0',
                   'xml' , function(data) {
                alert(data);
            });
        });

- . , , , . , , . ajax- URL- , URL- , .. . . https://stackoverflow.com/search?q=calling+webservice+from+another+domain+using+jquery

+5

pokrate, , . php-, rss, jquery .

( php):

<?php
    $session = curl_init($_GET['url']);
    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    $xml = curl_exec($session);
    header("Content-Type: text/xml");appropriately
    echo $xml;
    curl_close($session);
?>

javascript:

function get_rss_feed() {

    $(".content").empty();

    var feed = "http://dev.chriscurddesign.co.uk/burns/p/rc_rss.php?rcf_id=0";

    $.get("feedproxy.php?url=" + feed, function(d) {

        $(d).find('item').each(function() {

            var $item = $(this);
            var title = $item.find('title').text();
            var link = $item.find('link').text();

            var html = '<div class="entry"><a href="' + link + '" target="_blank">' + title + '</a></div>';

            $('.content').append(html);
        });

    });
};

Me = Happy Bunny:)

+1
0

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


All Articles