AJAX mw.util.wikiscript with POST

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

AJAX mw.util.wikiscript with POST

Toni Hermoso Pulido-3
Hello,

for different custom extensions I've been doing something like this with
GET:

        $.get( mw.util.wikiScript(), {
                format: 'json',
                action: 'ajax',
                rs: 'MyExt::MyFunction',
                rsargs: [param1, param2]
        }, function(data) {
                // console.log(data);
        });

MyExt::MyFunction is in $wgAjaxExportList[].

However, since now I have too much data for a URL (414 HTTP error) I'd
prefer to use POST. So far I have not found a proper way to build it.
Any idea or advice?

Thanks!

--
Toni Hermoso Pulido
http://www.cau.cat
http://www.similis.cc

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: AJAX mw.util.wikiscript with POST

Alex Monk
You should probably use the API rather than that. See
https://www.mediawiki.org/wiki/API:Extensions


On 3 September 2014 16:42, Toni Hermoso Pulido <[hidden email]> wrote:

> Hello,
>
> for different custom extensions I've been doing something like this with
> GET:
>
>         $.get( mw.util.wikiScript(), {
>                 format: 'json',
>                 action: 'ajax',
>                 rs: 'MyExt::MyFunction',
>                 rsargs: [param1, param2]
>         }, function(data) {
>                 // console.log(data);
>         });
>
> MyExt::MyFunction is in $wgAjaxExportList[].
>
> However, since now I have too much data for a URL (414 HTTP error) I'd
> prefer to use POST. So far I have not found a proper way to build it.
> Any idea or advice?
>
> Thanks!
>
> --
> Toni Hermoso Pulido
> http://www.cau.cat
> http://www.similis.cc
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: AJAX mw.util.wikiscript with POST

Toni Hermoso Pulido-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

If no other choice, I will do some rewriting.
I'll inspect for examples of POST here:
http://www.mediawiki.org/wiki/Category:API_extensions

Thanks Alex,

El 03/09/14 a les 17:59, Alex Monk ha escrit:

> You should probably use the API rather than that. See
> https://www.mediawiki.org/wiki/API:Extensions
>
>
> On 3 September 2014 16:42, Toni Hermoso Pulido <[hidden email]>
> wrote:
>
>> Hello,
>>
>> for different custom extensions I've been doing something like
>> this with GET:
>>
>> $.get( mw.util.wikiScript(), { format: 'json', action: 'ajax',
>> rs: 'MyExt::MyFunction', rsargs: [param1, param2] },
>> function(data) { // console.log(data); });
>>
>> MyExt::MyFunction is in $wgAjaxExportList[].
>>
>> However, since now I have too much data for a URL (414 HTTP
>> error) I'd prefer to use POST. So far I have not found a proper
>> way to build it. Any idea or advice?


- --
Toni Hermoso Pulido
http://www.cau.cat
http://www.similis.cc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJUB2R3AAoJELt+jnuNHMW+heQP/jHfco4TXYjuz1PieJKPCjjv
doPSeockY0nlpE5R19T3vQZRJgm5RxCi9rgkyezEr8gSogyrD4pA+OFxgqY77GYD
sKx4qfsVvHqWYeNQuMbNEUgSmcFlVPGgeI/jCAIdoyjjlSaLCqnkrxfUcdfwjXc1
j8dAVLJmwZC8YdzI1RLehPWpNqc1EmYMJylnOdiNApOJ5Qk6bisLay7yct6bCJrQ
nfpbSGW9508HvXpyx3JC7MoipZcKEfD1G7PkV70A5ehqal9H3mmqq20uZfE++BRz
pocNrrrmaLxY7ly31wvTI1efG60atASqi969E+JjzAIq7Jh3nox+VBUnnmGewIfm
jn4bTa6jVDy+z97R08vA2RCo/jHMhU53q4qkeBUZR3/sS7y5uJgVlz+DlG1iWqkC
pRqPqw8LVcsQfntqCRfHKuxSUXMQhkMMxynBTbVjCXsT2U7xowtJ/rN4Qs4a0qXe
8/JtJ7n8wyqGZ3qqL25Mm67ONtFGAdlum0ShsaNzRqgjasNtYSAy9YunAvt4bU8t
QroAAszQhL5fvjX+On322ep1zjqkPDf079V7vimleYQconnphiBeMao52jy/aGUI
S2W8kqNVtGVUaD97SZ0iF7heKBElQWFMC5QElaOB3/6SYrMYiIxak1lcd5NGepYB
zDl1a+v373PGO0GDyBWE
=zsKh
-----END PGP SIGNATURE-----

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: AJAX mw.util.wikiscript with POST

Thomas Gries
Am 03.09.2014 um 20:56 schrieb Toni Hermoso Pulido:
> If no other choice, I will do some rewriting.
> I'll inspect for examples of POST here:
> http://www.mediawiki.org/wiki/Category:API_extensions
>

Another nice example is the extension AJAXPoll
http://www.mediawiki.org/wiki/Extension:AJAXPoll




_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: AJAX mw.util.wikiscript with POST

Krinkle
In reply to this post by Toni Hermoso Pulido-3
It couldn't be more simple I'm afraid. Replace "get" with "post".

Note that both of these are just shortcuts to the more advanced "$.ajax" method, so if the reduced set of options exposed in get() and post() isn't enough, just call ajax() directly.

https://api.jquery.com/jQuery.get/
https://api.jquery.com/jQuery.post/
https://api.jquery.com/jQuery.ajax/

— Krinkle

PS: Please use the Promise interface, not the callback parameters. Don't forget to handle errors, either.

PS2: While this will help you get the request over POST, the underlying subsystem you're communicating with (action=ajax) has been deprecated for many years now. Please rewrite these global functions in a more modular fashion by creating an API module.

https://www.mediawiki.org/wiki/API:Main_page

On 3 Sep 2014, at 17:42, Toni Hermoso Pulido <[hidden email]> wrote:

> Hello,
>
> for different custom extensions I've been doing something like this with
> GET:
>
> $.get( mw.util.wikiScript(), {
> format: 'json',
> action: 'ajax',
> rs: 'MyExt::MyFunction',
> rsargs: [param1, param2]
> }, function(data) {
> // console.log(data);
> });
>
> MyExt::MyFunction is in $wgAjaxExportList[].
>
> However, since now I have too much data for a URL (414 HTTP error) I'd
> prefer to use POST. So far I have not found a proper way to build it.
> Any idea or advice?
>
> Thanks!
>
> --
> Toni Hermoso Pulido
> http://www.cau.cat
> http://www.similis.cc
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: AJAX mw.util.wikiscript with POST

Toni Hermoso Pulido-3
Finally I managed to do it.

Thanks for the good advices!

El 09/05/2014 a les 06:43 PM, Krinkle ha escrit:

> It couldn't be more simple I'm afraid. Replace "get" with "post".
>
> Note that both of these are just shortcuts to the more advanced "$.ajax"
> method, so if the reduced set of options exposed in get() and post()
> isn't enough, just call ajax() directly.
>
> https://api.jquery.com/jQuery.get/
> https://api.jquery.com/jQuery.post/
> https://api.jquery.com/jQuery.ajax/
>
> — Krinkle
>
> PS: Please use the Promise interface, not the callback parameters. Don't
> forget to handle errors, either.
>
> PS2: While this will help you get the request over POST, the underlying
> subsystem you're communicating with (action=ajax) has been deprecated
> for many years now. Please rewrite these global functions in a more
> modular fashion by creating an API module.
>
> https://www.mediawiki.org/wiki/API:Main_page
>
> On 3 Sep 2014, at 17:42, Toni Hermoso Pulido <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>> Hello,
>>
>> for different custom extensions I've been doing something like this with
>> GET:
>>
>> $.get( mw.util.wikiScript(), {
>> format: 'json',
>> action: 'ajax',
>> rs: 'MyExt::MyFunction',
>> rsargs: [param1, param2]
>> }, function(data) {
>> // console.log(data);
>> });
>>
>> MyExt::MyFunction is in $wgAjaxExportList[].
>>
>> However, since now I have too much data for a URL (414 HTTP error) I'd
>> prefer to use POST. So far I have not found a proper way to build it.
>> Any idea or advice?
>>


--
Toni Hermoso Pulido
http://www.cau.cat
http://www.similis.cc

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