このような場合、ページのリダイレクトを行わずに、クライアント側からサーバー側で何らかの変更を加えたい場合に、AJAXがあります。
クリック イベントからAJAXを介してZend コントローラーアクションを呼び出します。
jQuery(function() {
jQuery('#changePwYes').click(function(){
$.ajax({
url: "myApp/public/index.php/controller-name/create-name-space/format/html",
type: "POST",
data:{mydata : 'test'}
success: function(html){
alert('Done');
},
error: function(jqXHR, textStatus, errorThrown){
alert('An error occurred);
}
});
});
});
controllerで、新しいactionを作成します。
public function createNameSpaceAction()
{
//Disable the layout rendering for the ajax request
$this->_helper->layout->disableLayout();
//Set no renderer in this case
$this->_helper->viewRenderer->setNoRender(true);
//Retrieve dada if needed
$myData = $_POST['mydata'];
$session = new Zend_Session_Namespace(Zend_Registry::get('config')->session->nameSpace);
$session->showBox = "0";
}