Reputation: 646
How to execute ajax request in zend framework 2? I am beginner specially for zend framework 2. so i am not sure how to disabled layout... for my json response.
Upvotes: 3
Views: 206
Reputation: 728
sounds like you want to execute ajax request in zf2.
$viewModel = new ViewModel();
$viewModel->setTerminal(true);
return $viewModel;
Upvotes: 2
Reputation: 7954
Your ajax url must be like this baseurl+'/yourcontroller/ajax'
And in your ajax Action
public function ajaxAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); //ajax dont wants a view
//you can access your params like this
echo $this->_helper->getParam('paramname');exit;
}
Upvotes: -1