Hi, Is it possible to submit my form (or part of my form) with an ajax request? I had been using dojo to do this, but having just read up on the prototype library, I think I''d rather use prototype. The one thing I don''t see (maybe I''m just missing it) is the ability to submit my form (actually just parse through an element and include all inputs as request parameters) with my request. Can I do this? Thanks, Ben
On 3/9/06, Ben Anderson <benanderson.us-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > Is it possible to submit my form (or part of my form) with an ajax > request? I had been using dojo to do this, but having just read up on > the prototype library, I think I''d rather use prototype. The one > thing I don''t see (maybe I''m just missing it) is the ability to submit > my form (actually just parse through an element and include all inputs > as request parameters) with my request. Can I do this? > Thanks, > Ben >I cannot answer you since I''m not an Ajax guru. I would just like to know why do you left dojo for prototype ?
Siegfried Puchbauer
2006-Mar-09 17:08 UTC
Re: [Prototype] Ajax.Request include form fields?
you have to do smth like this
$(''myform'').onsubmit=function(evt) {
var form = $(''myform'');
new Ajax.Request(form.action, {
method: form.method,
parameters: Form.serialize(form),
onSuccess: updateFunction
});
Event.stop(evt);
return false;
}
have a look at http://www.sergiopereira.com/articles/prototype.js.html for
the whole list of options
hth
On 3/9/06, Ben Anderson
<benanderson.us-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hi,
> Is it possible to submit my form (or part of my form) with an ajax
> request? I had been using dojo to do this, but having just read up on
> the prototype library, I think I''d rather use prototype. The one
> thing I don''t see (maybe I''m just missing it) is the
ability to submit
> my form (actually just parse through an element and include all inputs
> as request parameters) with my request. Can I do this?
> Thanks,
> Ben
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
--
Mit freundlichen Grüßen
Siegfried Puchbauer
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Event.observe(form, "submit", function(ev) {
el = Event.element(ev);
data = Form.serialize(el);
new Ajax.Request(el.getAttribute("action"), {
method:"post",
postBody:data
});
Event.stop(ev);
});
Something like that.
-Rob
Ben Anderson wrote:
>Hi,
>Is it possible to submit my form (or part of my form) with an ajax
>request? I had been using dojo to do this, but having just read up on
>the prototype library, I think I''d rather use prototype. The one
>thing I don''t see (maybe I''m just missing it) is the
ability to submit
>my form (actually just parse through an element and include all inputs
>as request parameters) with my request. Can I do this?
>Thanks,
>Ben
>_______________________________________________
>Rails-spinoffs mailing list
>Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
>http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>
>
oh, I didn''t see the Form object. Yes, that''ll do it. Thanks Siegfried! On 3/9/06, Siegfried Puchbauer <siegfried.puchbauer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you have to do smth like this > > $(''myform'').onsubmit=function(evt) { > > var form = $(''myform''); > > new Ajax.Request(form.action, { > method: form.method, > parameters: Form.serialize(form), > onSuccess: updateFunction > }); > > Event.stop(evt); > return false; > } > > have a look at > http://www.sergiopereira.com/articles/prototype.js.html for > the whole list of options > > hth > > > On 3/9/06, Ben Anderson <benanderson.us-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > Is it possible to submit my form (or part of my form) with an ajax > request? I had been using dojo to do this, but having just read up on > the prototype library, I think I''d rather use prototype. The one > thing I don''t see (maybe I''m just missing it) is the ability to submit > my form (actually just parse through an element and include all inputs > as request parameters) with my request. Can I do this? > Thanks, > Ben > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > -- > Mit freundlichen Grüßen > > Siegfried Puchbauer > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >
On Thursday 09 March 2006 08:58, Ben Anderson wrote:> Hi, > Is it possible to submit my form (or part of my form) with an ajax > request? I had been using dojo to do this, but having just read up on > the prototype library, I think I''d rather use prototype. The one > thing I don''t see (maybe I''m just missing it) is the ability to submit > my form (actually just parse through an element and include all inputs > as request parameters) with my request. Can I do this?your question was already answered, but I''d like to point out the wonderful documentation for prototype provided by Sergio Pereira at http://www.sergiopereira.com/articles/prototype.js.html I also have a del.icio.us tag for prototype docs I find: del.icio.us/jkitchen/prototype -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
yeah - that''s the documentation I was using (forgot to point that out). It''d be nice if it had clickability, though. Thanks for the delicious link :-) On 3/9/06, Jeremy Kitchen <kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org> wrote:> On Thursday 09 March 2006 08:58, Ben Anderson wrote: > > Hi, > > Is it possible to submit my form (or part of my form) with an ajax > > request? I had been using dojo to do this, but having just read up on > > the prototype library, I think I''d rather use prototype. The one > > thing I don''t see (maybe I''m just missing it) is the ability to submit > > my form (actually just parse through an element and include all inputs > > as request parameters) with my request. Can I do this? > > your question was already answered, but I''d like to point out the wonderful > documentation for prototype provided by Sergio Pereira at > http://www.sergiopereira.com/articles/prototype.js.html > > I also have a del.icio.us tag for prototype docs I find: > del.icio.us/jkitchen/prototype > > -Jeremy > > -- > Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org > > In the beginning was The Word and The Word was Content-type: text/plain > -- The Word of Bob. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >