Last modified: 2008-08-05 16:13:28 UTC
Often when working with the API I'll end up needing to do several parallel operations, such as with format=json and using callbacks. This can be annoying, requiring re-scraping the page to figure out what triggered what, and doing fragile matching in the process. An alternative I've found is to use eval() to generate a unique callback function for each object, eg: var url = wgServer + wgScriptPath + '/api.php?action=query&format=json&callback=usiCB' + i; eval('usiCB' + i + ' = function(tobj) { usiCB(tobj,' + i + ')}'); But this can be a pain for hundreds of parallel or potential operations. Per IRC convo with Roan a possible solution vector is a generic ID parameter for all formats: something like &requestid=foo or &apiid=foo could generate (in the various formats): ({ "id":"foo", "query": { }, }) <api id="foo"> array('api' => array('id' => 'foo', 'query' => ... This would greatly facilitate usage of parallel scripts by giving the calling code a way to trace back what requested the query.
Fixed in r38638