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>"
);
精彩评论