On Wed, Aug 29, 2012 at 6:03 PM, Alex Brollo <[email protected]> wrote:

> Ouch.... this is a little bit above my skill & understanding (really I
> discovered AJAX not far ago). . Where can I find some examples of API
> inter-project data exchage wth callback parameter?
>
> I.e: I'd like to get the raw content and the html rendering
> of File:I_promessi_sposi_(1840).djvu from wikisource, with an AJAX callback
> call. Which is the needed code?
>

Luckily, if you're using jQuery much of the low-level stuff can be taken
care of for you. Something like this should work for API calls,
automatically using the callback behind the scenes:

$.ajax({
  url: 'https://commons.wikimedia.org/w/api.php',
  data: {
    format: 'json',
    // ... various settings ...
   },
   dataType: 'jsonp' // this is the important one!
}).done(function(data) {
  // do some work here
  alert(JSON.stringify(data));
});

You can look up the various parameters for different queries in the online
help at https://commons.wikimedia.org/w/api.php and/or playing with the API
sandbox at https://commons.wikimedia.org/wiki/Special:ApiSandbox

-- brion
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to