serialize
serialize(formElement[, getHash = false]) -> String | object
Serialize form data to a string suitable for Ajax requests (default behavior) or, if optional getHash evaluates to true, an object hash where keys are form control names and values are data.
Depending of whether or not the optional parameter getHash evaluates to true, the result is either an object of the form {name: "johnny", color: "blue"} or a string of the form "name=johnny&color=blue", suitable for parameters in an Ajax request. This method mimics the way browsers serialize forms natively so that form data can be sent without refreshing the page.
As of Prototype 1.5 the preferred form of passing parameters to an Ajax request is with an object hash. This means you should pass true for the optional argument. The old behavior (serializing to string) is kept for backwards-compatibility.
Interactive example
The following code is all there is to it:
$('person-example').serialize()
// -> 'username=sulien&age=22&hobbies=coding&hobbies=hiking'
$('person-example').serialize(true)
// -> {username: 'sulien', age: '22', hobbies: ['coding', 'hiking']}
Try it for yourself!