jQuery in Action

The Form Plugin
273
The
semantic
parameter to
formSerialize()
deserves special note. When specified
as
true
, the serialized values will be in the order that they would be in if the form
were submitted through the conventional means, making any submission of these
values exactly emulate a browser submission. We should only use this when abso-
lutely necessary (it's usually not) because there's a performance penalty to be paid.
WARNING
The
semantic
flag will cause the order of the parameters to be specified
in the submitted data in semantic order, but what the server-side code
does with this order isn't under the control of the client-side code. For
example, when using servlets, a call to the
getParameterMap()
method
of the request instance won't preserve the submitted order.
We can use the Get Form Values Laboratory page to observe the behavior of these
commands. Load the page, and leaving the controls be, click the Serialize Form
button. This will execute a
formSerialize()
command on the test form as follows:
$('#testForm').formSerialize()
Command syntax: formSerialize
formSerialize(semantic)
Creates and returns a properly formatted and encoded query string from the values of all
successful controls in the wrapped form.
Parameters
semantic
(Boolean) Specifies that the order of the values in the query string follows
the semantic order of the elements--the order in which the elements are
declared in the form. This option can be much slower than allowing
random order.
Returns
The generated query string.
Command syntax: fieldSerialize
fieldSerialize(excludeUnsuccessful)
Creates and returns a properly formatted and encoded query string from the values of con-
trols in the wrapped form.
Parameters
excludeUnsuccessful
(Boolean) If true or omitted, specifies that any unsuccessful
controls in the wrapped set be ignored.
Returns
The generated query string.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.