Is it even possible to get JSON feed from Reddit and post it in my site. I’ve tried in two ways, both do not seem to work.
First approach
$.getJSON('http://www.reddit.com/.json?feed=HASH_HERE&user=USER_HERE', function (data) {
alert(data);
});
Output
XMLHttpRequest cannot load http://www.reddit.com/.json?feed=HASH_HERE&user=USER_HERE. Origin http://localhost:14102 is not allowed by Access-Control-Allow-Origin.
Second approach
var url = "http://www.reddit.com/.json?feed=HASH_HERE&user=USER_HERE";
$.getJSON(url + "?callback=?", null, function (data) {
alert(data);
});
Output
Uncaught SyntaxError: Unexpected token :
It is cross-domain issue. Reddit is giving the result as json format which is only not enough for making cross-domain request using getJSON like the second option.
Please check the below one for flickr web service,
Ref url for url for the above code.
Please check this site, they have given real time example for the cross-domain request.