hi, i m trying to submit a form without refreshing the page using Ajax. my code is like: --------------------------------------------------------------------------------------------------------------- <html> <head> <script type="text/javascript" src="scripts/prototype.js"></script> <script language="javascript"> function greet() { new Ajax.Updater(''myDiv'', ''action.php'', {method:''post''}); } </script> </head> <body> <form name=''myform'' id=''thisform'' action="action.php" method="post"> Name: <input id=''text1'' type="text" name="name" /> Age: <input id=''text1'' type="text" name="age" /> <input type="submit" onclick="greet();return false;"/> </form> <div id=''myDiv''>change here</div> </body> </html> ----------------------------------------------------------------------------------------------- in this sample, the ''action.php'' is just a simple program to display how many parameters are passed in and display some values. if i put ''return false'' in the submit button, there is no parameters submitted to the server; if i get rid of ''return false'', the page gets refreshed. is it possible to submit the form, but not to refresh the page? anyone can help me? thank you in advance! best regards --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hey There NeedForSpeed, Try observing the form''s submit event directly, an easy way to pass form parameters would be as followed. $("myForm").observe("submit", function(e){ var dto = Event.element(e).serialize(); new Ajax.Updater(''myDiv'', ''action.php'', {parameters:dto}); }); Cheers On Sep 1, 11:29 am, NeedForSpeed <liudi_w...-/E1597aS9LT0CCvOHzKKcA@public.gmane.org> wrote:> hi, > i m trying to submit a form without refreshing the page using Ajax. my > code is like: > --------------------------------------------------------------------------------------------------------------- > <html> > <head> > <script type="text/javascript" src="scripts/prototype.js"></script> > <script language="javascript"> > function greet() { > new Ajax.Updater(''myDiv'', ''action.php'', {method:''post''}); > } > </script> > </head> > <body> > > <form name=''myform'' id=''thisform'' action="action.php" method="post"> > Name: <input id=''text1'' type="text" name="name" /> > Age: <input id=''text1'' type="text" name="age" /> > <input type="submit" onclick="greet();return false;"/> > </form> > > <div id=''myDiv''>change here</div> > </body> > </html> > ----------------------------------------------------------------------------------------------- > in this sample, the ''action.php'' is just a simple program to display > how many parameters are passed in and display some values. > > if i put ''return false'' in the submit button, there is no parameters > submitted to the server; if i get rid of ''return false'', the page gets > refreshed. > > is it possible to submit the form, but not to refresh the page? anyone > can help me? > > thank you in advance! > > best regards--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Oh yeah, and stop the submit event in the listener! On Sep 1, 11:29 am, NeedForSpeed <liudi_w...-/E1597aS9LT0CCvOHzKKcA@public.gmane.org> wrote:> hi, > i m trying to submit a form without refreshing the page using Ajax. my > code is like: > --------------------------------------------------------------------------------------------------------------- > <html> > <head> > <script type="text/javascript" src="scripts/prototype.js"></script> > <script language="javascript"> > function greet() { > new Ajax.Updater(''myDiv'', ''action.php'', {method:''post''}); > } > </script> > </head> > <body> > > <form name=''myform'' id=''thisform'' action="action.php" method="post"> > Name: <input id=''text1'' type="text" name="name" /> > Age: <input id=''text1'' type="text" name="age" /> > <input type="submit" onclick="greet();return false;"/> > </form> > > <div id=''myDiv''>change here</div> > </body> > </html> > ----------------------------------------------------------------------------------------------- > in this sample, the ''action.php'' is just a simple program to display > how many parameters are passed in and display some values. > > if i put ''return false'' in the submit button, there is no parameters > submitted to the server; if i get rid of ''return false'', the page gets > refreshed. > > is it possible to submit the form, but not to refresh the page? anyone > can help me? > > thank you in advance! > > best regards--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
newbie request: can you expand on this? how does one go about stopping the submit event? thanks! On 9/1/07, Matt Foster <mattfoster01-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Oh yeah, and stop the submit event in the listener! > > On Sep 1, 11:29 am, NeedForSpeed <liudi_w...-/E1597aS9LT0CCvOHzKKcA@public.gmane.org> wrote: > > hi, > > i m trying to submit a form without refreshing the page using Ajax. my > > code is like: > > > --------------------------------------------------------------------------------------------------------------- > > <html> > > <head> > > <script type="text/javascript" src="scripts/prototype.js"></script> > > <script language="javascript"> > > function greet() { > > new Ajax.Updater(''myDiv'', ''action.php'', > {method:''post''}); > > } > > </script> > > </head> > > <body> > > > > <form name=''myform'' id=''thisform'' action="action.php" > method="post"> > > Name: <input id=''text1'' type="text" name="name" /> > > Age: <input id=''text1'' type="text" name="age" /> > > <input type="submit" onclick="greet();return false;"/> > > </form> > > > > <div id=''myDiv''>change here</div> > > </body> > > </html> > > > ----------------------------------------------------------------------------------------------- > > in this sample, the ''action.php'' is just a simple program to display > > how many parameters are passed in and display some values. > > > > if i put ''return false'' in the submit button, there is no parameters > > submitted to the server; if i get rid of ''return false'', the page gets > > refreshed. > > > > is it possible to submit the form, but not to refresh the page? anyone > > can help me? > > > > thank you in advance! > > > > best regards > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---