1
当我尝试通过过滤器从我的WordPress wp-json中获取信息时,我得到以下响应:拒绝执行来自'....“的脚本,因为它的MIME类型(“应用/ JSON”)不是可执行文件,并严格MIME类型检查被启用。angular:json返回“拒绝执行脚本”
var newsApi = 'http://mywebsite.com/wp-json/?filter[category_name]=news?_jsonp=JSON_CALLBACK';
// This should go in a service so we can reuse it
$http.jsonp(newsApi).
success(function (data, status, headers, config) {
$scope.news = data;
console.log(data);
}).
error(function(data, status, headers, config) {
console.log('Post load error.');
});
'URL'必须具有'callback = JSON_CALLBACK'作为查询参数,url应该像'http://mywebsite.com/wp-json/?filter [category_name] = news?_jsonp = JSON_CALLBACK&callback = JSON_CALLBACK' –
另外我我不确定,但在URL中有两个'?'。可能第二个必须是'&'? –
谢谢!有用 – user3581731