【发布时间】:2014-01-28 06:21:29
【问题描述】:
其实我用的是ajax调用,我的代码示例在这里..请不要介意语法
$.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 响应。有没有办法做到这一点?
【问题讨论】:
标签: php ajax zend-framework