I’m trying to convert RSS to JSON but when I use console in Chrome I get this error
XMLHttpRequest cannot load
http://www.blastcasta.com/feed-to-json.aspx?feedurl=http://www.startalkradio.net/?page_id=354.
Origin null is not allowed by Access-Control-Allow-Origin.
jQuery:
$(document).ready(function() {
var rss_url = "http://www.blastcasta.com/feed-to-json.aspx?feedurl=http://www.startalkradio.net/?page_id=354";
$.ajax({
type : 'GET',
url : rss_url,
succces : function(data) {
$.each(data.rss, function(i, item) {
$("#results").append('<ul>' + item.channel.item.description + '</ul>');
});
},
dataType : 'json',
async : true
});
function fetchRss(data) {
$.each(data.rss, function(i, item) {
$("#results").append('<ul>' + item.channel.item.description + '</ul>');
});
}
});
UPDATE: this answer suggests using the Google Feed API which has been deprecated. Other options include Superfeedr: Converting RSS to JSON
That error happens because the RSS file is not in your server, so you are violating the Access-Control-Allow-Origin.
Try this plugin that is used for cross-domain purposes with RSS:
http://jquery-howto.blogspot.com/2009/11/cross-domain-rss-to-json-converter.html
EDIT:
Library download link:
http://code.google.com/p/lomodroid/source/browse/src/functions/jquery.jgfeed.js
Live demo with twitter:
http://jsfiddle.net/oscarj24/NbDWb/
Live demo with the link used in the question:
http://jsfiddle.net/oscarj24/NbDWb/3/
This will convert RSS to JSON