Check out the jquery.form plugin found here: http://malsup.com/jquery/form/.

It has form serialization methods built in. I think it may be exactly
what you need.



On Apr 3, 10:45 am, Matt Wilson <[EMAIL PROTECTED]> wrote:
> I have a form with a bunch of checkboxes.   They all have the same
> name and different values. This form posts to a page that does a bunch
> a stuff based on the checked checkboxes.
>
> I want to change the form to use AJAX to update a div on the page.  I
> need help figuring out how to post the form with AJAX.
>
> I am using something like this right now:
>
> var x = serialize_all_the_form_elements();
>
> $("div#formresults").load("/save", x);
>
> I am having trouble building that object x.  Right now, to grab all
> the checked checkboxes and put them into x, I do this:
>
> x.checked_values = $("input:checkbox:checked").map(function ()
> { return this.value; });
>
> However, when I send this over the network, x.checked_values gets
> serialized as [Object object], which is useless.
>
> Questions:
>
> 1. Is there a much simpler way to post a form with ajax so I don't
> have to manually serialize everything?
>
> 2. How do I convert a list of checkbox jquery objects into an array of
> strings?
>
> TIA
>
> Matt

Reply via email to