开发者

return meta redirect in ajax response

I want to return a meta redirect tag in my Ajax response. How can this be done ?

I have a Zend Controller where in my init function I开发者_开发技巧 check for the session expiration. If the session already expired and the request was ajax I want to return a meta redirect tag to my log in controller.

If there is a better was please let me know.

public function init()
{
    if ($sessionExpired)
    {
        if($this->_request->isXmlHttpRequest()){               
            $this->getResponse()->setBody('<meta http-equiv="refresh" content="1;url='.APP_URL.'/authentication/loginform'.'">');                        
    }
}


Instead of redirecting with a meta tag, you could use the window.location property:

 $this->getResponse()->setBody(
     "<script>"
    ."window.location.href='".APP_URL."/authentication/loginform';"
    ."</script>"
     );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜