I am new to APIs and they seem to keep hanging me up. I keep getting the following error:
The 'Access-Control-Allow-Origin' header has a value 'http://null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.
Here is my JS:
var url = "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1";
$('#quotebutton').on('click', function(e) {
e.preventDefault();
$.ajax( {
url: "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
success: function(data) {
var post = data.shift(); // The data is an array of posts. Grab the first one.
$('#quote-title').text(post.title);
$('#quote').html(post.content);
// If the Source is available, use it. Otherwise hide it.
if (typeof post.custom_meta !== 'undefined' && typeof post.custom_meta.Source !== 'undefined') {
$('#quote-source').html('Source:' + post.custom_meta.Source);
} else {
$('#quote-source').text('');
}
},
cache: false
});
});