Hi

I guess you are not familiar with AJAX. In most cases you run an AJAX
call, as the name suggest, asynchronous, so it can run and complete no
matter how the rest of the page behaves. Instead of getting a result
back, your AJAX call will be sent to another page to get the result
from there, which is what you probably see (check with firebug).

You will have to handle the redirect client side if you want to use
something like this. Return the url you want to redirect to. I would
(as I do not see how the client side script or form looks like) take
the json object, add a key for the form and one for the redirect url.
If there is something in the redirect url, then redirect, otherwise
use the form part and populate your form.

On Mon, Sep 6, 2010 at 4:26 AM, Meroe Kush <[email protected]> wrote:
> Hello,
>
>
>
> I'm trying to figure out the best way to redirect after a form is processed
> and found valid via processAjax.  Here is my controller code:
>
>
>
> public function addAction() {
>
>             $form = new App_Forms_Users_Add ();
>
>             if ($this->getRequest ()->isXmlHttpRequest () &&
> $this->getRequest ()->isPost ()) {
>
>                   $response = $form->processAjax ( $this->getRequest
> ()->getPost ());
>
>                   if ($response == 'true') {
>
>                         $formData = $form->getValues ();
>
>                         $last_id = $this->UserModel->add ( $formData
> );
>
>
> $this->_redirect('/backend/users/index');
>
>                   } else {
>
>                         $this->_helper->json
> ($response);
>
>                   }
>
>             }
>
>             $this->view->form = $form;
>
>
>
>       }
>
>
>
> Everything works just fine except the redirect.  Can I not redirect after a
> post?  Any help would be appreciated.



-- 
Greetings,
Christian Riesen
http://christianriesen.com/ - My personal page
http://toreas.com/ - Toreas a free fantasy novel
http://gamewiki.net/ - Open Videogames Wiki

Reply via email to