I’m using jquery in Zend Framework, it’s my first trial. I’ve already found out through another question, that I can change the response by changing the context like so:
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('myaction', 'html'); $ajaxContext->initContext();
Now this has helped a lot but a new problem has shown:
My page consists of different responseSegments and when I responde to an Ajax request by changing the Context, my other ResponseSegments also ‘think’ they are sending Ajax but they’re not. The front controller asks for a viewscript.ajax.phtml… which is wrong, it should be viewscript.phtml (exists).
In the meantime I figured out how to solve this and because I think others will encounter the same problem in the future, I will answer my own question here:
In my ActionSetup.php (or bootstrap.php if the action setup is not separated) I needed to make sure that actions are only pushed to the action stack, if the request was no XmlHttpRequest.
The only thing that was missing was an if statement:
The whole thing looks like that: