Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2569

Joomla! 5.x Coding • Re: Receiving JSON data (is this AJAX???)

$
0
0
I am a bit too rusty.
Thanks for that. I'm not sure "rusty" is correct, this seems to be new in J5(or 4).
I now have something that's working, although a bit poor imnvho.

The js

Code:

let url = 'index.php?option=com_lmf&view=posts&task=' + task;let data = new FormData();data.append('cid', ids);$app = Factory::getApplication();$postieIds = explode(',', $app->getInput()->get('cid', [], 'string'));const options = {method: 'POST',body: data};response = await fetch(url, options).then(fSuccess, fFailure);
works with an array "ids", although it's not an array inside the FormData objects (I hate js!). So, adjusting the php to

Code:

$app = Factory::getApplication();$postieIds = explode(',', $app->getInput()->get('cid', [], 'string'));
gives me the array I want, albeit of strings rather than ints, but that works ok.

Statistics: Posted by MarkRS — Tue Feb 13, 2024 12:26 pm



Viewing all articles
Browse latest Browse all 2569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>