JSONP is exactly the reason why cross-domain works. It allows you to  
use callbacks and get the data from there.

ie. something like the following will work to en.wikipedia.org from  
your domain as well:

<code>
$.ajax({
        url: 'http://en.wikipedia.org/w/api.php',
        'data' : {
                format: 'json',
                action: 'opensearch',
                search: 'Hello',
                namespace: '0|4|10'
        },
        dataType: 'jsonp', // adds a callback-parameter to data
        success: function( response ) {
                if ( !response || !response[0] || !response[1].length ) {
                        return; // error or no results
                }
                alert( response[1].join( ',' ) ); // results !
        }
});
</code>

Op 28 mrt 2011, om 19:57 heeft SALIL P A het volgende geschreven:

> i have built a simple mockup file in salilpa.com/wiki. here i have
> implemented the Opensearch
> <http://www.mediawiki.org/wiki/API:Opensearch> method.
> it has a simple form structure and on click opens a new tab with the
> results.
>
> i could not ajaxify the request because of the restriction
> Origin http://salilpa.com is not allowed by Access-Control-Allow- 
> Origin.
>
> i have used jquery and plan to use it extensively once the code is  
> hosted on
> wiki server
>
> expecting valuable comments
>
> Salil P A
>
>
>
> On Mon, Mar 28, 2011 at 11:04 PM, Krinkle <[email protected]>  
> wrote:
>
>> Because of that an API Sandbox may be able to be created completely
>> client side.
>>
>> The extension would contain a little bit of php to load the modules
>> and pass
>> interface messages, declare the .i18n files and the rest could be
>> an OOP JavaScript module using jQuery (which is in core now) to  
>> do .post
>> /get/ajax/getJSON and UI elements (jQuery UI).
>>
>> I'm not saying we should do it completely client side, simply because
>> we can.
>> But if there's no need for a new API module etc. that would be  
>> nice :-)
>>
>> To save some generation time, the basic html structure should  
>> probably
>> be
>> built server-side through subclassing SpecialPage.
>>
>> --
>> Krinkle
>>
>> Op 28 mrt 2011, om 18:43 heeft Roan Kattouw het volgende geschreven:
>>
>>> 2011/3/28 Bryan Tong Minh <[email protected]>:
>>>> That would be the best way to go. You really don't want to do this
>>>> manually. Every API modules has a function  
>>>> getFinalParamDescription()
>>>> which will give you the parameter description, including the  
>>>> defaults
>>>> and the variable type. Best look at  
>>>> ApiBase::makeHelpMsgParameters()
>>>> how this is handled by the documentation generator.
>>>>
>>> I said this on IRC but I'll repeat it here: the API exposes the data
>>> from getFinalParamDescription() and friends through  
>>> action=paraminfo.
>>>
>>> Roan Kattouw (Catrope)
>>>
>>> _______________________________________________
>>> Wikitech-l mailing list
>>> [email protected]
>>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
>>
>> _______________________________________________
>> Wikitech-l mailing list
>> [email protected]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
> _______________________________________________
> Wikitech-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l


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

Reply via email to