2016-09-06 2 views
0

다음과 같이 Zend 프레임 워크 컨트롤러가 있습니다.Javascript에서 Zend 프레임 워크 컨트롤러로 변수 전달

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; 
    } 
} 

나는 아래와 같은 일부 데이터이 "viewHandlerAction"방법에 HTTP POST 요청을하고있다.

$http({ 
     method : "POST", 
     url : "myData/my-data/viewHandler", 
     data : JSON.stringify(formData) 
    }). 
    then(function(response) { 
     //console.log(response); 

    }, function(response) { 
     //console.log(response); 
    }); 

I는이 요청을 보내고 난 클라이언트 측으로부터 전송 된 데이터 (formData)에 액세스 할 수없는 problem.But없이 제어기로부터 데이터를 수신 할 수있다.

어디에서 잘못 했습니까?

답변

0

답을 찾았습니다. 동작 방법에서 우리는 다음과 함께 매개 변수 목록을 얻을 수 있습니다.

$data = $this->getRequest()->getPost(); 
+0

젠드 프레임 워크는 또한 이것을 돕기 위해'params()'컨트롤러 플러그인을 제공합니다. 먼저 요청을 받고 싶지 않으면'$ this-> params() -> fromPost();'문서는 https://framework.zend.com/manual/2.4/en/에서 찾을 수 있습니다. modules/zend.mvc.plugins.html –

관련 문제