Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Receiving POST data from AJAX call


Go to End


989 Views

Avatar
Faloude

Community Member, 55 Posts

6 January 2017 at 12:46pm

Edited: 06/01/2017 11:58pm

I've got a form that submits through AJAX (domain.com/page/FormAction), calling FormAction() to process the form. AJAX is functioning properly and all form data is sent through POST.

For some reason though, I noticed I can't retrieve the data using $this->getRequest()->param('field_value'); which is the way I usually get POST data. I have to use $this->requestParams['value'] instead.

$this->getRequest()->param('field') // returns null
$this->requestParams // returns an array with all form data

I don't mind using the requestParams property instead, but why does the first method (param) not function for AJAX calls?