Get post data, Zend Framework

2019-04-03 19:14发布

I want to fetch posted data. But I am using no form. The data is postet by a jquery script with method post and I would like to fetch it.

I know how to fetch parameters

$id = $this->getRequest ()->getParam ( 'id', null );

and form values

$message = $form->getValue ( 'message' );

however I want to access post data and not parameters or form values. Any ideas?

4条回答
萌系小妹纸
2楼-- · 2019-04-03 19:27

Here is my solution;)

$this->getRequest()->getPost('id', null);
查看更多
Lonely孤独者°
3楼-- · 2019-04-03 19:34

Here is an other example:

$this->getRequest()->getPost()->toArray()
查看更多
Bombasti
4楼-- · 2019-04-03 19:47

Try this:

$request = $this->getRequest();
$request->getPost('field_name');
查看更多
Evening l夕情丶
5楼-- · 2019-04-03 19:50

Actually, this might be more of what you're looking for.

$this->getRequest()->getRawBody();

https://framework.zend.com/manual/1.12/en/zend.controller.request.html

查看更多
登录 后发表回答