arno arno - 4 months ago 21
Ajax Question

Zend getParams not returing url params

I have a query:
https://myaddress.ee/admin/usersearchajax?country=EE&query=arno

$this->_request->getParam('query');

returns: NULL

var_dump($_REQUEST['query']);

returns: string(5) "arno"

How to fix this problem? I mean how to get GET values with zend framework?
Lets assume i can't change the query string.

zend version 1.11.11

public function usersearchajaxAction(){
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender( true );

$userService = new Application_Services_User();

$userList = $userService->searchByName($this->_request->getParam('query'));
$this->_helper->json($userService->getArrayForAutoComplete($this->_request->getParam('query'), $userList));

}


I found the problem, there was and override of $_GET variable in my project.
So it is fix now. thank you all for reading and thinking about this

Answer

instead of

$this->_request->getParam('query');

use this

$this->_getParam('query');

there is no need to use request action helper in Action to get this params

or try to use this way which uses request action helper

$request  = $this->getRequest();
$query = $request->getParam('query');

hope this link will help you