0

I have a dynamically generated form that I would like to submit using Ajax. The form contains some input fields and some checkboxes - so the total number of checkboxes that will be submitted is obviously unknown at the start. By "dynamically generated" I mean the contents and the id's of the form elements are pulled from a DB and again, I never know how many there will be in advance.

From what I understand, to submit it with Ajax I need to execute something like this in my javascript function:

xmlhttp.open("GET","/incl/myfile.php?var[]=a&var[]=b&...", true);

My problem is generating those "var[]=a&var[]=b&..." lists. Particularly, I have a hard time understanding how to generate it for those checkboxes, which may or may not be checked.

Is there something that will capture the entire content of the form input fields and format it into a nice GET url query? A plugin perhaps? Something in JQuery maybe?

2 Answers 2

1

Yes, take a look at jQuery's serialize method. http://api.jquery.com/serialize/

Sign up to request clarification or add additional context in comments.

Comments

1

You want jQuery's .serialize() method.

Comments

Your Answer

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.