I have a Zend framework Controller as below.
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
class myDataController extends AbstractActionController
{
public function indexAction()
{
return array();
}
public function viewHandlerAction()
{
echo $_REQUEST['value'];
$json = new JsonModel(array("abc"=>"1"));
return $json;
}
}
I am making a HTTP post request to this "viewHandlerAction" method with some data as below.
$http({
method : "POST",
url : "myData/my-data/viewHandler",
data : JSON.stringify(formData)
}).
then(function(response) {
//console.log(response);
}, function(response) {
//console.log(response);
});
I can send this request and receive the data from the controller without any problem.But I can not access the data(formData) I sent from the client side.
Where have I done wrong?
Found the answer. In the action method we can get the parameter list with following.
$data = $this->getRequest()->getPost();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.