如何使用Angularjs摆脱的mediawiki API数据? [英] How to get data from mediawiki api using Angularjs?
问题描述
当我尝试使用Angularjs $ http.get()来访问维基API,CORS问题发生。这里是我的code
While I try to access wiki api using Angularjs $http.get(), CORS issues occured. Here is my code
$ http.get(<一href=\"http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India\" rel=\"nofollow\">http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India')
.success(功能(数据){
的console.log('数据'+数据);
});
$http.get('http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India') .success(function(data){ console.log('data' +data); });
这是错误讯息
XMLHtt prequest无法加载<一个href=\"https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India\" rel=\"nofollow\">https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India.无访问控制允许来源标头的请求的资源present。因此,原产地'空'是不允许访问。
XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exintro=&titles=India. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
推荐答案
使用JSONP 跨站点请求。
这篇关于如何使用Angularjs摆脱的mediawiki API数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!