Form Serialization

FORMs are sometimes used for XMLHttpRequest. Most "AJAX" libraries
(DOJO, YUI, prototype, et c) already provide functionality for
serializing a FORM (even if indirectly, by associating a FORM with an
XMLHttpRequest ).

The process is to through the form and concatenate strings based on
form's successful controls.

This Serializing of a FORM by hand should not be necessary. Browsers
that support FORM submission serialize a form to a data set
automatically upon submission.

Proposal:

interface HTMLFormElement {
  String getDataSetString
  String toJSONString
};

toJSONString would return an object literal that contains the FORM
element's successful controls, using names as key and an LIST for each
key's value.

getDataSetString() would return a serialized data set representation
of the FORM's successful controls. It would look just like what you
see in a GET query string or a POST body.

For Binary Data, you can encode as JS escapes.

These methods should also apply to HTMLFieldsetElement.

Received on Thursday, 16 August 2007 22:29:13 UTC