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!
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 toniher@cau.cat 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 Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
-----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 toniher@cau.cat 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
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
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 toniher@cau.cat 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 Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
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 <toniher@cau.cat mailto:toniher@cau.cat> 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?
wikitech-l@lists.wikimedia.org