0

Note that I am totally new to Javascript, but due to complications, this is the only language that I can use here. I have spent many hours looking for a solution, but can't seem to find one.

I want to edit a Wikipedia page through the MediaWiki API from my local machine using either Javascript or jQuery - that's it. I don't need a mechanism to obtain an edit token, that is all sorted. All I need is to be able to edit a page, and so far every method I've seen fails because of the 'Access-Control-Allow-Origin' header.

svick
  • 214,528
  • 47
  • 357
  • 477
  • You'll probably want to look into the JSONP version of the API to avoid cross-site restrictions. See http://stackoverflow.com/questions/3873636/no-response-from-mediawiki-api-using-jquery for an example. – Paul Roub Aug 21 '14 at 20:31
  • Thanks for the advice, but I need to post this request, so JSONP isn't an option. –  Aug 21 '14 at 20:53

1 Answers1

0

Is this just for local development, or for a production deployment? If it's just something you need running on your own machine, follow the instructions over on this question to disable the cross-origin security.

If it's for a production deployment, you could create a proxy-of-sorts which queries/posts to the target MediaWiki installation using one of the various server-side libraries available for querying MediaWiki (e.g. NodeJS), and set up your own simple API to query your proxy. I think that should work as long as you pass your edit token along with the request, but having never done it I'm not 100% on that.

Community
  • 1
  • 1
Andru
  • 6,536
  • 3
  • 19
  • 15