0

What is the difference between this?

$("form").serialize();

and this?

var theForm = $("form");
$(theForm[0]).serialize();

How do you get the second sample to serialize like the first one?

asked Oct 1, 2011 at 21:26

3 Answers 3

2

try this:

var theForm = $("form");
theForm.eq(0).serialize();
answered Oct 1, 2011 at 21:28
Sign up to request clarification or add additional context in comments.

Comments

2

First one selects all forms and serializes all form fields.

Second one selects form fields from FIRST form and serializes them

answered Oct 1, 2011 at 21:28

1 Comment

the problem is the second one doesn't serialize the first form.
0

Or you could use in one line:

$("form:first").serialize();

answered Oct 1, 2011 at 22:01

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.