Reputation: 333
I want to develop a small RSS reader that will fetch the XML documents from various websites. I thought that XHR would be simple, if a user can manipulate the browser UI to fetch an obviously "Cross Origin" web page, shouldn't JavaScript code be able to do so as easily? apparently no :/
Here is what I'm trying to do:
var xhr = new XMLHttpRequest();
// A real feed URL, its web server should allow CORS
xhr.open('GET', 'http://feeds2.feedburner.com/thenextweb');
xhr.send();
Locally opening my HTML page (file:///) makes the Origin null and the response empty, but if i access the page trough a local web server (i tried Python and Node server scripts), the Origin is not null but the response is still empty.
I know there are enough XHR questions around, but can someone point out what am i missing?
Upvotes: 0
Views: 534
Reputation: 1867
Feedburner does not support CORS (yet). These are the headers I receive from feedburner when executing your code from jsfiddle:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
ETag: ckkcnAejDTcF+4d0Kj6kftZuq+0
Last-Modified: Tue, 30 Jul 2013 19:56:16 GMT
Content-Encoding: gzip
Transfer-Encoding: chunked
Date: Tue, 30 Jul 2013 19:58:11 GMT
Expires: Tue, 30 Jul 2013 19:58:11 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Server: GSE
If it supported CORS you should see an Access-Control-Allow-Origin
header in there
Upvotes: 3