I’m trying to read in data from a percussion RSS feed and then parse it and return it to a UL list. I have the following code but it’s not working at all. Any suggestions?
<title>XML & AJAX</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript"></script>
<script type="text/javascript"> <br />
$(document).ready(function(){ <br />
var FEED_URL = "http://10.0.8.50:9980/feeds/rss/mwsu.edu/news-feed-2/"; <br />
$.ajax({ <br />
url : FEED_URL, <br />
type : "GET", <br />
success : function(xml) { <br />
var items = xml.getElementsByTagName('item'); <br />
var item, title, desc, thumb, swf, i, l; <br />
for(i=0, l < items.length; i < l; i++){ <br />
item = items[i]; <br />
title = item.getElementByTagName("title")[0].textContent; <br />
link = item.getElementByTagName("link")[0].textContent; <br />
$('#News').append('<li><a href="' + link + '">' + title + '</a></li>'); <br />
} <br />
} <br />
}); <br />
}); <br />
</script>
I’ve been trying to peice things from the web to make this work but can’t seem to get it to. I have saved a local copy of the Percussion XML file and it doesn’t work with it either.
So I have new code and tested it with a basic XML item. Below is the code that I’m using. When I place in the Percussion published XML link, it doesn’t work anymore.
Your code looks good. The problem is that ajax doesn’t support cross domain requests for XML content, which is what you’re doing when you specify the IP address and port for your FEED_URL.
If you are looking to get the above code running on the same IIS server that your CM1 site is running off of, you can setup your IIS server to proxy the RSS feed connection from Tomcat through IIS, which would then allow you to use the FEED_URL of “/feeds/rss/mwsu.edu/news-feed-2/”.
I have tested such a configuration on my local machine using your code, and it works. If this setup would work for what you’re looking to do, we can get on a quick call so I can show you how to setup this proxy configuration in IIS. Let me know if this would help.