I use $.getto parse an RSS feed in jQuery with code like this:
$.get(rssurl, 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()
}
});
});
However, due to a single-origin policy, I get the following error:
No header "Access-Control-Allow-Origin" is present on the requested resource.
Fortunately, I have access to the source server as this is my own dynamically created RSS feed.
My question is: how to set the Access-Control-Allow-Origin header on the source server?
Edit
I am using PHP and I think my web server is Apache.
source
share