其实我使用Ajax调用我的代码示例在这里..请不要介意语法如何强制页面重新加载在Zend的PHP
$.ajax(
url: "mysite/action1",
success: function(resp) {
$("#divId").html(resp);
});
像这个我加载响应文本到一个DIV标签。现在我的问题是在zend控制器中,我试图检查一个条件,如会话过期意味着重定向到登录页面,或者发送该动作的响应html代码。
public function action1Action() {
$login = new Zend_Session_Namespace('login');
if (isset($login->employee_id)) {
echo $html;
} else{
$this->view->headMeta()->appendHttpEquiv('refresh','1');
//$this->_helper->redirector->gotoUrl($this->view->baseUrl());
//$this->_helper->redirector('index', 'index');
}
}
我想这三种方式
$this->view->headMeta()->appendHttpEquiv('refresh','1'); -- Nothing happening
$this->_helper->redirector->gotoUrl($this->view->baseUrl()); and $this->_helper->redirector('index', 'index'); -- loads login page within the div tag (as it is taking as the ajax response)
我只是想重新加载页面。就像触发浏览器刷新按钮来实现我想要的..请提出任何想法来解决我的问题..
注意:我想从服务器端的页面重新加载,而不是检查ajax响应..有没有办法去做吧?
是的,从前端我们可以做到,但我只是想从后端做..没有办法做到这一点吗? – Dhivya