Redirect does not work after using AjaxContext

In my controller init () method, I call AjaxContext-Helper and set it for some methods / actions in this controller. For example:

public function init()
{
    $ajaxContext = $this->_helper->getHelper('AjaxContext');
    $ajaxContext->addActionContext('setlabel', 'html');
    $ajaxContext->initContext();
}

Now that I want to use a redirect from an ajax request to a non-ajax method ...

$this->redirector->gotoSimple('manage', 'team', null, array('id' => $teamID));

I have a problem that the page does not load. I assume that since AjaxContext messed up the headers.

I tried clearHeaders and clearContexts before the redirect, but nothing works.

[edit] in the appropriate ajaxed method (AjaxContent) I usually respond with an ajax response to myviewscript.ajax.phtml. But in a specific case, I now want to redirect to a normal action without an ajax in another controller. [/ Edit]

Any ideas? Thanks!

+3
2

jason , javascript. , javascript- myview.ajax.phtml:

$url = $this->view->url(array('controller' => 'team', 
                              'action' => 'manage', 
                              'id' => $teamID), null, null);

$this->view->response = '<script type="text/javascript">
                           window.location = "'.$url.'"
                        </script>';
+2

Ok. , .

, redirector Zend_Controller_Action.

, :

$this->redirector->gotoSimple('manage', 'team', null, array('id' => $teamID));

:

$this->_helper->redirector->gotoSimple('manage', 'team', null, array('id' => $teamID));

, , . , .

, _redirect Redirector XHR XHR. XHR? ?

Edit:

. , w/r/t : - XHR, . Redirector . XHR/Ajax... 301/302, , . .

, , . -, :

  • Ajax, , - ; , ... , JSON... , .
  • , , , , 1.
  • , Javascript. window.location = whatever .
+3

Source: https://habr.com/ru/post/1713002/


All Articles