0
我是API的新手,他们似乎一直在阻止我。我不断收到以下错误:使用API时出错Error
'Access-Control-Allow-Origin'标头的值'http://null'不等于提供的原点。因此不允许原产地'null'访问。
这里是我的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
});
});
我只是想在一个restles客户您的网址,我得到的错误: “对不起,你不能在这个网站上发帖。”看起来像http://quotesondesign.com/wp-json/posts的POST请求实际上是试图创建一个帖子。请咨询他们的API –