In such case, when you want to make some changes on server side from client side without page redirection, we have AJAX.
Call a Zend controller action from your click event trough AJAX :
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);
}
});
});
});
In your controller, create a new 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";
}
php
runs way before your jquery gets executed. – Jai Jan 18 '13 at 7:16