1

While I try to access wiki api using Angularjs $http.get(), CORS issues occured. Here is my code

$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); });

And this is the error message

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.

1

3 Answers 3

1

Use JSONP for cross-site requests.

Sign up to request clarification or add additional context in comments.

Comments

0

Check the following SO answer regarding CORS:

CORS, Cordova, AngularJs $http and file:// confusion

As well as the mentioned in the comment:

http://www.html5rocks.com/en/tutorials/cors/

Comments

0

See Manual:CORS and API:Cross-site requests. Specifically, you need to set $wgCrossSiteAJAXdomains and add an origin parameter to your request.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.