1

I have a form with a large number of dynamically generated elements. in the submit handler I would like to get all the data at once rather than going by each id. Is there anyway to do it?

3 Answers 3

3

your question is not very clear but maybe you're looking for serialize() or serializeArray() jQuery methods

http://api.jquery.com/serialize/
http://api.jquery.com/serializeArray/

e.g

The .serializeArray() method creates a JavaScript array of objects, ready to be encoded as a JSON string. It operates on a jQuery object representing a set of form elements. The form elements can be of several types:

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

Comments

3
jQuery('your-form-selector').submit(function() {
    var yourKeyMap = jQuery(this).serializeArray();
});

Comments

3

You could use:

var yourFormData = $('#yourFormId').serialize()

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.