Thursday, December 10, 2009

Re: form->input keeps value after submit is presed

Or you can use for ajax a normal jQuery function like:

function SaveDataByAjax(postid){

$.ajax({
type: "GET",
url: "http://www.domain.com/posts/getviewbyajax/"+postid,
data: "",
success: function(msg){
...;
}
});

spor la treaba ;)

> $this->render('url'=>'/posts/view'.$this->data['Post']['id'],'ajax');
On 9 Dez., 09:08, Andrei BOGDAN <andrei.bogdan.m...@gmail.com> wrote:
> I want to redirect to /posts/view/Id_view. So my code shoul look like:
> [code]
> $this->render('url'=>'/posts/view'.$this->data['Post']['id'],'ajax');
> [/code]
> Is this the correct way?
> -
> Andrei Bogdan
>
> 2009/12/9 Dave <davidcr...@gmail.com>:
>
> > Don't render add_success, redirect to the action you want
>
> > On Tue, Dec 8, 2009 at 4:07 PM, Andrei BOGDAN <andrei.bogdan.m...@gmail.com>
> > wrote:
>
> >> Hello,
> >> My add action in comments_controller looks like this now:
> >> [code]
> >> function add() {
> >>                if (!empty($this->data)) {
> >>                 if ($this->Comment->save($this->data)) {
> >>                        $comments = $this->Comment->find('all',
> >> array('conditions' =>
> >> array('post_id' => $this->data['Comment']['post_id']), 'recursive' =>
> >> -1));
> >>                        unset($this->data['Comment']);
> >>                        $this->data = $this->Comment->create();
> >>                        $this->set(compact('comments'));
> >>                        $this->render('add_succes','ajax');
> >>                        } else { $his->render('add_failure','ajax');}
> >>                }
> >>        }
> >> [/code]
> >> I used with firebug to debug the app and I saw that when I render
> >> 'add_succes' $_POST keeps the old values instead of clearing them.
>
> >> -
> >> Andrei Bogdan
>
> >> 2009/12/8 John Andersen <j.andersen...@gmail.com>:
> >> > Ok, sorry, didn't see you were using the $this->data variable later
> >> > inside the if statement, so please move the statement:
>
> >> > $this->data = $this->Comment->create();
>
> >> > after your find statement. The find statement uses the data from the
> >> > $this->data variable!
>
> >> > Tell us if the above fixes your problem, or what Chickenhen wrote did!
> >> > Enjoy,
> >> >   John
>
> >> > On Dec 7, 10:00 pm, Andrei BOGDAN <andrei.bogdan.m...@gmail.com>
> >> > wrote:
> >> >> I've change my code and the add action from comments controller looks
> >> >> like this:
> >> >> [code]
> >> >> function add() {
> >> >>                 if (!empty($this->data)) {
> >> >>                  if ($this->Comment->save($this->data)) {
> >> >>                   $this->data = $this->Comment->create();
> >> >>                         $comments = $this->Comment->find('all',
> >> >> array('conditions' =>
> >> >> array('post_id' => $this->data['Comment']['post_id']), 'recursive' =>
> >> >> -1));
> >> >>                         $this->set(compact('comments'));
> >> >>                         $this->render('add_succes','ajax');
> >> >>                         } else { $his->render('add_failure','ajax');}
> >> >>                 }
> >> >>         }
> >> >> [/code]
> >> > [snip]
>
> >> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> >> > others with their CakePHP related questions.
>
> >> > You received this message because you are subscribed to the Google
> >> > Groups "CakePHP" group.
> >> > To post to this group, send email to cake-php@googlegroups.com
> >> > To unsubscribe from this group, send email to
> >> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> >> > athttp://groups.google.com/group/cake-php?hl=en
>
> >> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> >> with their CakePHP related questions.
>
> >> You received this message because you are subscribed to the Google Groups
> >> "CakePHP" group.
> >> To post to this group, send email to cake-php@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscribe@googlegroups.com For more options, visit this group
> >> athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate