Try JSONP (add "&callback=CALLBACKFUNCTION" to your URL; jQuery: $.getJSON ( "URL&callback=?"  will work)


On Mon, Sep 1, 2014 at 10:58 AM, Kristian Kankainen <kristian@eki.ee> wrote:
Hello!

Since I don't get even the simplest code snippet to work (e.g [1]) I want to ask a really simple question.

Am I allowed to query the Wikipedia API [2] from any domain if I specify the 'origin' field to correspond my domain? Or is there a whitelist with only perhaps all relevant WikiMedia sites blocking me from this. I have tried more elaborate ajax script parameters following all bot best practices but I get CORS blocked.

The code snippet mentioned above was modified only with "'origin': location.origin" but I get the error:
"SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data"
(using jquery 1.11.0 and Firefox 31.0).

Best wishes
Kristian Kankainen

[1]: https://www.mediawiki.org/wiki/Manual:CORS
[2]: https://et.wikipedia.org/w/api.php

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api