views:

59

answers:

4

I'm working on an ajax application that makes extensive use of jQuery. I'm not worried about whether or not the application degrades gracefully.

So far I have been using Malsup's excellent jQuery form plugin to create forms that submit ajax requests. (For example, to submit updated record information.)

However I am considering dispensing with form tags altogether, and instead manually constructing $.post() statements when needed.

I'm wondering: What are peoples' thoughts on the best way to submit a large amount of information to the server - considering graceful degradation is not a requirement. Are there perils with just using $.post()?

Thanks in advance

+3  A: 

Nope, not at all. That's all the plugin is doing anyway, under the hood.

The form tag does at least provide you with a nice structural grouping of your form tags, so that you can query for them more easily, though.

David Pfeffer
A: 

I stopped using FORM tags some time ago, but I also have a set of captured users that I know exactly what platform they are using.

Michael Bray
+1  A: 

You've said it yourself - the peril is that it won't degrade gracefull!

Have jQuery add an extra field called UsingjQuery, then output your results based on whether this field is set or not.

This way users with javascript turned off (mobile clients, etc) will still be able to submit.

edit: Saw you mentioned 'degrades gracefully' but somehow didn't see it said 'not worried about' first!

Having a form tag does allow one javascript trick that jQuery doesn't support without: $('form').reset() ...

MQA
Thanks for the reply. Like I said, I'm not worried about whether or not the app degrades gracefully. It's for internal use.
Travis
A: 

I agree with David Pfeffer, however, I would also make the point that on occasion, form tags can get in your way. I've specifically had problems where I wanted multiple forms inside of a table, but that caused really ugly problems with positioning. So, I wound up dropping just the input elements in, copying them into a form that was elsewhere on the page, then submitting that form. It was a bit of a pain in the butt.

If you can do away with forms, and aren't worried about degradation, then I would highly consider it.

Topher Fangio