如何使用Angularjs摆脱的mediawiki API数据? [英] How to get data from mediawiki api using Angularjs?

查看:157
本文介绍了如何使用Angularjs摆脱的mediawiki API数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆