Having an issue with responseRedirect

robdog

Well-known member
Code:
        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            $this->getDynamicRedirect(),
            new XenForo_Phrase('successfully_joined_our_mailing_list'));

I can get the redirect to work but I thought there would be a dialog that would display while the redirect is taking place with the phrase "successfully_joined_our_mailing_list".

Or should I use something different than responseRedirect?

Thanks.
 
By default, responseRedirect uses a silent redirect with no message. If you call it via an action that is loaded with AJAX, such as <form class="AutoValidator">, the message will be displayed in a sliding panel at the top of the page, as you see when you save your profile info.
 
I am having a problem with responseRedirect as well. In my case, the redirection is NOT occuring :(

I am using the AutoValidator class, so my form is being posted using AJAX, but even if I take the AutoValidator off, that is not working. My redirection return is just

PHP:
$return = XenForo_Link::buildPublicLink('threads', $thread);
            return $this->responseRedirect(
                XenForo_ControllerResponse_Redirect::SUCCESS,
                $return,
                new XenForo_Phrase('ds_autolockthreads_limit_success'));

The idea is, since the form is posted using ajax, to cause a reload of the thread being viewed. Because the limit was applied, the 'Set thread limit' block won't show again, otherwise, the value can be changed as much as you want, before you actually reload the page...

What am I doing wrong?
 
I am having a problem with responseRedirect as well. In my case, the redirection is NOT occuring :(

I am using the AutoValidator class, so my form is being posted using AJAX, but even if I take the AutoValidator off, that is not working. My redirection return is just

PHP:
$return = XenForo_Link::buildPublicLink('threads', $thread);
            return $this->responseRedirect(
                XenForo_ControllerResponse_Redirect::SUCCESS,
                $return,
                new XenForo_Phrase('ds_autolockthreads_limit_success'));

The idea is, since the form is posted using ajax, to cause a reload of the thread being viewed. Because the limit was applied, the 'Set thread limit' block won't show again, otherwise, the value can be changed as much as you want, before you actually reload the page...

What am I doing wrong?
Have you added data-redirect="on" to the form? I've come across this as well and adding that with the AutoValidator class to the form makes it work as expected.
 
That was it! Thank you very much, Onimua! The better way would be to return another template, using AJAX, but as I am learning things, to redirect makes my custom template to be hidden due to my restrictions, so thank you so much! It worked :D
 
Top Bottom