<input type="text" name="data[Comment][e_mail]" id="e_mail" /> //It's
working with simple POST with page refresh =)
But in ajax call the fields are saved empty !! that means cake
AddComment action doesn't get the values from the fields !!!
This is my action AGAIN
function AddComment(){
$this->layout = 'ajax';
Configure::write('debug', 0);
$this->autoRender = false;
if ($this->RequestHandler->isAjax()) {
$this->Comment->create();
$this->Comment->save($this->data);
echo 'success';
}
exit();
}
And Keep In Mind That I'm using simple HTML form (Not CakePHP form
helpers)
I hope u Can help me guys with a simple Ajax call with HTML basic
forms example
regards
Abraham
On Jul 28, 12:38 pm, AD <adcake...@googlemail.com> wrote:
> hi,
> you have to name your input right to get the data into $this->data. e.g.
>
> <input type="text" name="data[Comment][e_mail]" id="e_mail" />
>
> greets
> Andreas
>
> Abraham Boray schrieb:
>
> > I'm not usin'Formhelper 4 some reason , and I'm working with a
> > simple commentform::
>
> > /**********form*************/
> > <formaction="" method="get" name="CommentForm" id="CommentForm">
> > <input name="username" type="text" id="username" />
> > <input type="text" name="e_mail" id="e_mail" />
> > <input type="text" name="a_url" id="a_url" />
> > <textarea name="content" id="content" rows="5"></textarea>
> > <input name="CommentItBtn" id="CommentItBtn" type="button"
> > class="button" value="Comment" />
>
> > ///////*************My Model(Table) ,Fields names
> > are ::********///////
>
> > -id
> > -post_id
> > -content
> > -a_url
> > -e_mail ...
>
> > ////*************And I'm doing an ajax
> > call ::*********************/////
>
> > var data=$('#CommentForm').formSerialize();
> > //I'musingaFormplugins to retrieve data from theform
> > eg:e_mail...@cf.ma&....
>
> > $.ajax({
> > type: "POST",
> > url: "comments/AddComment/",
> > data: data,
> > success: function(msg){
> > alert( "Data status: " + msg );
> > }
> > });
>
> > /*******controller action==> AddComment ******//
> > function AddComment(){
>
> > $this->layout = 'ajax';
>
> > if ($this->RequestHandler->isAjax()) {
> > if ($this->Comment->save($this->data)) {
> > echo 'success';
> > }
>
> > Configure::write('debug', 0);
> > $this->autoRender = false;
> > exit();
> > } }
>
> > The comment is not saved !! ,and I get no error ,I dnt get even the "
> > echo 'success';" of the action !
> > Firebug indicat that there is no error ,and the ajax call is
> > performed !
>
> > Thanks in advance , I hope find a solution
> > Regards
> > Abraham
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment