Re: ajax form submission - nothing happens

2008-11-08 Thread omar.laverde

Hi Carlos,

i am fallowing that book, i find one error, a missing right parentesis
in the comments_controller.php but i can´t find the other two errors
you mention, could you tell me please where are they.


Thank You

On 2 nov, 14:45, carlos ferrandis [EMAIL PROTECTED] wrote:
 Hi. Are you following the exercise in the book: Implementing Ajax
 Features, chapter 8? if so I might me able to tell you that I found 3
 errors on it. Reading your code I fix the last one. let me know then I
 can drop you the code corrected.

 carlos

 On 31 out, 15:13, Kieron [EMAIL PROTECTED] wrote:

  Hi,

  I am trying to add a commentsformto a blog post, updating the page
  withajax, specifically using prototype.js.
  I've usedajax-form, however when I press the submit button
  absolutely nothing happens.
  I've tried theajaxsubmit method with the same result. If I submit
  theformwithoutajaxit works fine.

  my view code is as follows:

  echo $ajax-form('/comments/
  add','post',array('update'='comments','url'='/comments/add'));
  echo $form-input('Comment.name');
  echo $form-input('Comment.content');
  echo 
  $form-input('Comment.post_id',array('type'='hidden','value'=$post['Post']

  ['id']));
  echo $form-end('Add Comment');

  the add action in the comments controller is as follows:

  function add() {
  if (!empty($this-data)) {
  $this-Comment-create();
  if ($this-Comment-save($this-data)) {
  $comments = 
  $this-Comment-find('all',array('conditions'=array('post_id'=$this-data['Comment']

  ['post_id']),'recursive'=-1));
  $this-set(compact('comments'));
  $this-render('add_success','ajax');
  } else {
  $this-render('add_failure', 'ajax');
  }
  }
  }

  and the created source is as follows:

div id=comments
  formid=form283226270 onsubmit=event.returnValue = false;
  return false; method=post action=/blog/comments/add
  fieldset style=display:none;
input type=hidden name=_method value=POST /
  /fieldset
  script type=text/javascript
  //![CDATA[
  Event.observe('form283226270', 'submit', function(event) { 
  newAjax.Updater('comments','/blog/comments/add', {asynchronous:true,
  evalScripts:true, parameters:Form.serialize('form283226270'),
  requestHeaders:['X-Update', 'comments']}) }, false);
  //]]
  /script
  div class=input text
label for=CommentNameName/label
input name=data[Comment][name] type=text maxlength=100
  value= id=CommentName /
  /div
  div class=input textarea
label for=CommentContentContent/label
textarea name=data[Comment][content] cols=30 rows=6
  id=CommentContent /textarea
  /div
  input type=hidden name=data[Comment][post_id] value=7
  id=CommentPostId/
  div class=submit
input type=submit value=Add Comment /
  /div
  /form
/div

  Does anyone know what might be wrong?

  I'd appreciate any feedback as I've spent a whole day trying to solve
  this and have no desire to quit the whole cakephp thing over something
  like this!

  Thanks
  Kieron.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: ajax form submission - nothing happens

2008-11-08 Thread carlos ferrandis

Hi Omar

yes, the parentesis you mentioned in the page 121 is one of the
errors, and you might find in the page 116 where it says Installing
the Prototype where it asks you to include a javascript line in your
default.ctp. you should encapsulate the line between ? and ? and you
need to echo the line as well, so it ends up like:
?=javascript-link(array('prototype'));?

another thing that I had to change was the line 15 on the listing 8.7
page 120, that line did not work to me and I found a corrected one,
please try:

?=$ajax-form('/comments/
add','post',array('update'='comments','url'='/comments/add'));?

good luck

Carlos

On 8 nov, 14:49, omar.laverde [EMAIL PROTECTED] wrote:
 Hi Carlos,

 i am fallowing that book, i find one error, a missing right parentesis
 in the comments_controller.php but i can´t find the other two errors
 you mention, could you tell me please where are they.

 Thank You

 On 2 nov, 14:45, carlos ferrandis [EMAIL PROTECTED] wrote:

  Hi. Are you following the exercise in the book: Implementing Ajax
  Features, chapter 8? if so I might me able to tell you that I found 3
  errors on it. Reading your code I fix the last one. let me know then I
  can drop you the code corrected.

  carlos

  On 31 out, 15:13, Kieron [EMAIL PROTECTED] wrote:

   Hi,

   I am trying to add a commentsformto a blog post, updating the page
   withajax, specifically using prototype.js.
   I've usedajax-form, however when I press the submit button
   absolutely nothing happens.
   I've tried theajaxsubmit method with the same result. If I submit
   theformwithoutajaxit works fine.

   my view code is as follows:

       echo $ajax-form('/comments/
   add','post',array('update'='comments','url'='/comments/add'));
       echo $form-input('Comment.name');
       echo $form-input('Comment.content');
       echo 
   $form-input('Comment.post_id',array('type'='hidden','value'=$post['Post']

   ['id']));
       echo $form-end('Add Comment');

   the add action in the comments controller is as follows:

           function add() {
                   if (!empty($this-data)) {
                           $this-Comment-create();
                           if ($this-Comment-save($this-data)) {
                                   $comments = 
   $this-Comment-find('all',array('conditions'=array('post_id'=$this-data['Comment']

   ['post_id']),'recursive'=-1));
                                   $this-set(compact('comments'));
                                   $this-render('add_success','ajax');
                           } else {
                                   $this-render('add_failure', 'ajax');
                           }
                   }
           }

   and the created source is as follows:

     div id=comments
       formid=form283226270 onsubmit=event.returnValue = false;
   return false; method=post action=/blog/comments/add
       fieldset style=display:none;
         input type=hidden name=_method value=POST /
       /fieldset
       script type=text/javascript
   //![CDATA[
   Event.observe('form283226270', 'submit', function(event) { 
   newAjax.Updater('comments','/blog/comments/add', {asynchronous:true,
   evalScripts:true, parameters:Form.serialize('form283226270'),
   requestHeaders:['X-Update', 'comments']}) }, false);
   //]]
       /script
       div class=input text
         label for=CommentNameName/label
         input name=data[Comment][name] type=text maxlength=100
   value= id=CommentName /
       /div
       div class=input textarea
         label for=CommentContentContent/label
         textarea name=data[Comment][content] cols=30 rows=6
   id=CommentContent /textarea
       /div
       input type=hidden name=data[Comment][post_id] value=7
   id=CommentPostId/
       div class=submit
         input type=submit value=Add Comment /
       /div
       /form
     /div

   Does anyone know what might be wrong?

   I'd appreciate any feedback as I've spent a whole day trying to solve
   this and have no desire to quit the whole cakephp thing over something
   like this!

   Thanks
   Kieron.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: ajax form submission - nothing happens

2008-11-08 Thread omar.laverde

Thank you so much carlos,

it seems i have change the 3 errors that you mention, but i dont know
why i have still the error that the submit button doesn`t do nothing,
the code that i change in the files are this way:

- app/views/posts/view.ctp

?php echo $ajax-form('/comments/
add','post',array('update'='comments','url'='/comments/add'));?
?php echo $form-input('Comment.name');?
?php echo $form-input('Comment.content');?
?php echo $form-
input('Comment.post_id',array('type'='hidden','value'=$post['Post']
['id']));?
?php echo $form-end('Add Comment');?

- app/views/layouts/default.ctp

head
titleMy Cake Blog Application/title
?php echo $html-css('cake.generic'); ?
?php echo $javascript-link(array('prototype')); ?
/head

- app/controllers/comments_controller.php

function add() {
if (!empty($this-data)) {
$this-Comment-create();
if ($this-Comment-save($this-data)) {
$comments = $this-Comment-
find('all',array('conditions'=array('post_id'=$this-data['Comment']
['post_id']),'recursive'=-1));
$this-set(compact('comments'));
$this-render('add_success','ajax');
} else {
$this-render('add_failure','ajax');
}
}

}


The form html source code is this way

form id=form123915682 onsubmit=event.returnValue = false; return
false; method=post action=/Blog/comments/addfieldset
style=display:none;input type=hidden name=_method
value=POST //fieldsetscript type=text/javascript
//![CDATA[
Event.observe('form123915682', 'submit', function(event) { new
Ajax.Updater('comments','/Blog/comments/add', {asynchronous:true,
evalScripts:true, parameters:Form.serialize('form123915682'),
requestHeaders:['X-Update', 'comments']}) }, false);
//]]
/scriptdiv class=input textlabel for=CommentNameName/
labelinput name=data[Comment][name] type=text maxlength=100
value= id=CommentName //divdiv class=input textarealabel
for=CommentContentContent/labeltextarea name=data[Comment]
[content] cols=30 rows=6 id=CommentContent /textarea/
divinput type=hidden name=data[Comment][post_id] value=1
id=CommentPostId /div class=submitinput type=submit
value=Add Comment //div/form

- And in the mozilla firebug i get these errors:

- syntax error
var $name = 'Js';\n
- Event.observe is not a function
Event.observe('form1428557839', 'submit'...rs:['X-Update',
'comments']}) }, false);

I dont know where else could the error be, thank you so much for your
help.



On 8 nov, 10:55, carlos ferrandis [EMAIL PROTECTED] wrote:
 Hi Omar

 yes, the parentesis you mentioned in the page 121 is one of the
 errors, and you might find in the page 116 where it says Installing
 the Prototype where it asks you to include a javascript line in your
 default.ctp. you should encapsulate the line between ? and ? and you
 need to echo the line as well, so it ends up like:
 ?=javascript-link(array('prototype'));?

 another thing that I had to change was the line 15 on the listing 8.7
 page 120, that line did not work to me and I found a corrected one,
 please try:

 ?=$ajax-form('/comments/
 add','post',array('update'='comments','url'='/comments/add'));?

 good luck

 Carlos

 On 8 nov, 14:49, omar.laverde [EMAIL PROTECTED] wrote:

  Hi Carlos,

  i am fallowing that book, i find one error, a missing right parentesis
  in the comments_controller.php but i can´t find the other two errors
  you mention, could you tell me please where are they.

  Thank You

  On 2 nov, 14:45, carlos ferrandis [EMAIL PROTECTED] wrote:

   Hi. Are you following the exercise in the book: Implementing Ajax
   Features, chapter 8? if so I might me able to tell you that I found 3
   errors on it. Reading your code I fix the last one. let me know then I
   can drop you the code corrected.

   carlos

   On 31 out, 15:13, Kieron [EMAIL PROTECTED] wrote:

Hi,

I am trying to add a commentsformto a blog post, updating the page
withajax, specifically using prototype.js.
I've usedajax-form, however when I press the submit button
absolutely nothing happens.
I've tried theajaxsubmit method with the same result. If I submit
theformwithoutajaxit works fine.

my view code is as follows:

echo $ajax-form('/comments/
add','post',array('update'='comments','url'='/comments/add'));
echo $form-input('Comment.name');
echo $form-input('Comment.content');
echo 
$form-input('Comment.post_id',array('type'='hidden','value'=$post['Post']

['id']));
echo $form-end('Add Comment');

the add action in the comments controller is as follows:

function add() {
if (!empty($this-data)) {
$this-Comment-create();
if ($this-Comment-save($this-data)) {
$comments = 

Re: ajax form submission - nothing happens

2008-11-08 Thread omar.laverde

Hi I fiugured out what my error was,

i download the ajax javascript file and i didn´t re named when i
download it the name was prototype-1.6.0.3.js so i change it to
prototype.js, and then all just work fine.

Thanks

On 8 nov, 11:29, omar.laverde [EMAIL PROTECTED] wrote:
 Thank you so much carlos,

 it seems i have change the 3 errors that you mention, but i dont know
 why i have still the error that thesubmitbuttondoesn`t do nothing,
 the code that i change in the files are this way:

 - app/views/posts/view.ctp

 ?php echo $ajax-form('/comments/
 add','post',array('update'='comments','url'='/comments/add'));?
 ?php echo $form-input('Comment.name');?
 ?php echo $form-input('Comment.content');?
 ?php echo 
 $form-input('Comment.post_id',array('type'='hidden','value'=$post['Post']

 ['id']));?
 ?php echo $form-end('Add Comment');?

 - app/views/layouts/default.ctp

 head
 titleMy Cake Blog Application/title
 ?php echo $html-css('cake.generic'); ?
 ?php echo $javascript-link(array('prototype')); ?
 /head

 - app/controllers/comments_controller.php

 function add() {
 if (!empty($this-data)) {
 $this-Comment-create();
 if ($this-Comment-save($this-data)) {
 $comments = 
 $this-Comment-find('all',array('conditions'=array('post_id'=$this-data['Comment']

 ['post_id']),'recursive'=-1));
 $this-set(compact('comments'));
 $this-render('add_success','ajax');
 } else {
 $this-render('add_failure','ajax');
 }
 }

 }

 The form html source code is this way

 form id=form123915682 onsubmit=event.returnValue = false; return
 false; method=post action=/Blog/comments/addfieldset
 style=display:none;input type=hidden name=_method
 value=POST //fieldsetscript type=text/javascript
 //![CDATA[
 Event.observe('form123915682', 'submit', function(event) { new
 Ajax.Updater('comments','/Blog/comments/add', {asynchronous:true,
 evalScripts:true, parameters:Form.serialize('form123915682'),
 requestHeaders:['X-Update', 'comments']}) }, false);
 //]]
 /scriptdiv class=input textlabel for=CommentNameName/
 labelinput name=data[Comment][name] type=text maxlength=100
 value= id=CommentName //divdiv class=input textarealabel
 for=CommentContentContent/labeltextarea name=data[Comment]
 [content] cols=30 rows=6 id=CommentContent /textarea/
 divinput type=hidden name=data[Comment][post_id] value=1
 id=CommentPostId /div class=submitinput type=submit
 value=Add Comment //div/form

 - And in the mozilla firebug i get these errors:

 - syntax error
 var $name = 'Js';\n
 - Event.observe is not a function
 Event.observe('form1428557839', 'submit'...rs:['X-Update',
 'comments']}) }, false);

 I dont know where else could the error be, thank you so much for your
 help.

 On 8 nov, 10:55, carlos ferrandis [EMAIL PROTECTED] wrote:

  Hi Omar

  yes, the parentesis you mentioned in the page 121 is one of the
  errors, and you might find in the page 116 where it says Installing
  the Prototype where it asks you to include a javascript line in your
  default.ctp. you should encapsulate the line between ? and ? and you
  need to echo the line as well, so it ends up like:
  ?=javascript-link(array('prototype'));?

  another thing that I had to change was the line 15 on the listing 8.7
  page 120, that line did not work to me and I found a corrected one,
  please try:

  ?=$ajax-form('/comments/
  add','post',array('update'='comments','url'='/comments/add'));?

  good luck

  Carlos

  On 8 nov, 14:49, omar.laverde [EMAIL PROTECTED] wrote:

   Hi Carlos,

   i am fallowing that book, i find one error, a missing right parentesis
   in the comments_controller.php but i can´t find the other two errors
   you mention, could you tell me please where are they.

   Thank You

   On 2 nov, 14:45, carlos ferrandis [EMAIL PROTECTED] wrote:

Hi. Are you following the exercise in the book: Implementing Ajax
Features, chapter 8? if so I might me able to tell you that I found 3
errors on it. Reading your code I fix the last one. let me know then I
can drop you the code corrected.

carlos

On 31 out, 15:13, Kieron [EMAIL PROTECTED] wrote:

 Hi,

 I am trying to add a commentsformto a blog post, updating the page
 withajax, specifically using prototype.js.
 I've usedajax-form, however when I press thesubmitbutton
 absolutely nothing happens.
 I've tried theajaxsubmit method with the same result. If Isubmit
 theformwithoutajaxit works fine.

 my view code is as follows:

 echo $ajax-form('/comments/
 add','post',array('update'='comments','url'='/comments/add'));
 echo $form-input('Comment.name');
 echo $form-input('Comment.content');
 echo 
 

Re: ajax form submission - nothing happens

2008-11-02 Thread carlos ferrandis

Hi. Are you following the exercise in the book: Implementing Ajax
Features, chapter 8? if so I might me able to tell you that I found 3
errors on it. Reading your code I fix the last one. let me know then I
can drop you the code corrected.

carlos

On 31 out, 15:13, Kieron [EMAIL PROTECTED] wrote:
 Hi,

 I am trying to add a commentsformto a blog post, updating the page
 withajax, specifically using prototype.js.
 I've usedajax-form, however when I press the submit button
 absolutely nothing happens.
 I've tried theajaxsubmit method with the same result. If I submit
 theformwithoutajaxit works fine.

 my view code is as follows:

     echo $ajax-form('/comments/
 add','post',array('update'='comments','url'='/comments/add'));
     echo $form-input('Comment.name');
     echo $form-input('Comment.content');
     echo 
 $form-input('Comment.post_id',array('type'='hidden','value'=$post['Post']

 ['id']));
     echo $form-end('Add Comment');

 the add action in the comments controller is as follows:

         function add() {
                 if (!empty($this-data)) {
                         $this-Comment-create();
                         if ($this-Comment-save($this-data)) {
                                 $comments = 
 $this-Comment-find('all',array('conditions'=array('post_id'=$this-data['Comment']

 ['post_id']),'recursive'=-1));
                                 $this-set(compact('comments'));
                                 $this-render('add_success','ajax');
                         } else {
                                 $this-render('add_failure', 'ajax');
                         }
                 }
         }

 and the created source is as follows:

   div id=comments
     formid=form283226270 onsubmit=event.returnValue = false;
 return false; method=post action=/blog/comments/add
     fieldset style=display:none;
       input type=hidden name=_method value=POST /
     /fieldset
     script type=text/javascript
 //![CDATA[
 Event.observe('form283226270', 'submit', function(event) { 
 newAjax.Updater('comments','/blog/comments/add', {asynchronous:true,
 evalScripts:true, parameters:Form.serialize('form283226270'),
 requestHeaders:['X-Update', 'comments']}) }, false);
 //]]
     /script
     div class=input text
       label for=CommentNameName/label
       input name=data[Comment][name] type=text maxlength=100
 value= id=CommentName /
     /div
     div class=input textarea
       label for=CommentContentContent/label
       textarea name=data[Comment][content] cols=30 rows=6
 id=CommentContent /textarea
     /div
     input type=hidden name=data[Comment][post_id] value=7
 id=CommentPostId/
     div class=submit
       input type=submit value=Add Comment /
     /div
     /form
   /div

 Does anyone know what might be wrong?

 I'd appreciate any feedback as I've spent a whole day trying to solve
 this and have no desire to quit the whole cakephp thing over something
 like this!

 Thanks
 Kieron.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



ajax form submission - nothing happens

2008-10-31 Thread Kieron

Hi,

I am trying to add a comments form to a blog post, updating the page
with ajax, specifically using prototype.js.
I've used ajax-form, however when I press the submit button
absolutely nothing happens.
I've tried the ajax submit method with the same result. If I submit
the form without ajax it works fine.

my view code is as follows:

echo $ajax-form('/comments/
add','post',array('update'='comments','url'='/comments/add'));
echo $form-input('Comment.name');
echo $form-input('Comment.content');
echo $form-
input('Comment.post_id',array('type'='hidden','value'=$post['Post']
['id']));
echo $form-end('Add Comment');

the add action in the comments controller is as follows:

function add() {
if (!empty($this-data)) {
$this-Comment-create();
if ($this-Comment-save($this-data)) {
$comments = $this-Comment-
find('all',array('conditions'=array('post_id'=$this-data['Comment']
['post_id']),'recursive'=-1));
$this-set(compact('comments'));
$this-render('add_success','ajax');
} else {
$this-render('add_failure', 'ajax');
}
}
}

and the created source is as follows:

  div id=comments
form id=form283226270 onsubmit=event.returnValue = false;
return false; method=post action=/blog/comments/add
fieldset style=display:none;
  input type=hidden name=_method value=POST /
/fieldset
script type=text/javascript
//![CDATA[
Event.observe('form283226270', 'submit', function(event) { new
Ajax.Updater('comments','/blog/comments/add', {asynchronous:true,
evalScripts:true, parameters:Form.serialize('form283226270'),
requestHeaders:['X-Update', 'comments']}) }, false);
//]]
/script
div class=input text
  label for=CommentNameName/label
  input name=data[Comment][name] type=text maxlength=100
value= id=CommentName /
/div
div class=input textarea
  label for=CommentContentContent/label
  textarea name=data[Comment][content] cols=30 rows=6
id=CommentContent /textarea
/div
input type=hidden name=data[Comment][post_id] value=7
id=CommentPostId/
div class=submit
  input type=submit value=Add Comment /
/div
/form
  /div

Does anyone know what might be wrong?

I'd appreciate any feedback as I've spent a whole day trying to solve
this and have no desire to quit the whole cakephp thing over something
like this!

Thanks
Kieron.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---