Capture all form items

Hey everyone,

So I’m using Codeigniter for form validation and would like to add some client-side validation with jQuery.

What I want to do is “capture” all the inputs, selects, textareas, etc. from a form and send all of that post data (as a JSON object) to my validation page in CodeIgniter, which would send back validation errors, etc. through an AJAX request.

Would simply looping through all the elements in the form be the best/easiest way to gather the $_POST data client-side (with jQuery)?

EDIT: Solved. jQuery’s serialize() function is exactly what I’m looking for.