[whatwg] Form Serialization Idea

I've cross-posted. Bad. I'm putting this back on WHAT WG

It's a web-app thing, but related to HTML5. HTML 5 has two lists.

On 9/24/07, Subbu Allamaraju <subbu.allamaraju at gmail.com> wrote:
> Does this approach take the enctype into account? What is the behavior if a
> given form can't be serialized for a given enctype?
>
Enctype could be used for serialization, I think.

If the enctype were text/plain, that would have to map to a default.
If the enctype were javascript:, then a user-defined serialization
technique could potentially be used (maybe for CSV excel-like data)

The get-form-data-to-javascript concept is addressed by Web Forms 2.0:

http://www.w3.org/Submission/web-forms2/#for-javascript

WF 2.0 maps all enctype to a JSON-like object. (They should mention
the JSON RFC.)

This still doesn't make it easy to get a data set string like you'd
want for submission via XHR. It's somewhat useful, and could be
modified. Here's what WF 2 says about <form action="javascript:;"/>,
They do this for ALL enctypes:

==============================================================
Encode the form data set by putting each name/value pair into a newly
created object using the names as attributes of that object and the
values as the values of those attributes. Execute the URI given by the
action attribute in the context of the document after having added the
aforementioned object to the start of the scope chain. Duplicate names
should cause the property to become an array, with each value
represented in the array. The response body is the return value of the
script.
==============================================================

"Execute the URI given by the action attribute in the context of the
document after having added the aforementioned object to the start of
the scope chain"

What is the name of the object?

Example:
<form action="javascript:alert( aforementionedObject );"><input
name="foo" value="bar"/></form>

And expect to get:
{
   "foo" : "bar"
}

Which would seem to match the JSON RFC. It seems like there should
also provision for whitespace/formatting. It's nice to see formatted,
indented code for debugging but not for production.

Adding aformentionedObject to the front of the scope chain would seem
to make it possible to then call aformentionedObject.toJSONString(
true ); iff aforementionedObject were an ecmascript object and not a
poorly duck-typed host object.

WF 2.0 provides no provision to get an encoded dataset as uri encoding.

WF 2.0 could be changed to handle uri-encoding of Data Set. If WF 2.0
were changed in such a way that would make it possible to run the
example and expect a result of

foo=bar

Garrett

> Cheers
> Subbu
-- 
Programming is a collaborative art.

Received on Monday, 24 September 2007 13:23:00 UTC