I am trying to retrieve JSON Data from the tumblr-API.
No problems when using jQuery
$.getJSON("http://api.tumblr.com/v2/blog/blog.com/posts?api_key=key&jsonp=?", function(data) {
console.log(data);
});
But trying to get the data with an XMLHttpRequest, i get the
XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost' is therefore not allowed access.
error msg.
var url = "http://api.tumblr.com/v2/blog/blog.com/posts?api_key=key";
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "json";
xhr.onload = function () {
console.log(xhr.response);
};
xhr.send();
I really want to get the data without jQuery. So what does jQuery that i am not doing? Thank you very much.