Progress28.ru

IT Новости
3 просмотров
Рейтинг статьи
1 звезда2 звезды3 звезды4 звезды5 звезд
Загрузка...

Javascript form serialize

Javascript form serialize

form-serialize

serialize form fields to submit a form over ajax

form-serialize supports two output formats, url encoded (default) or hash (js objects).

Lets serialize the following html form:

Returns a serialized form of a HTMLForm element. Output is determined by the serializer used. Default serializer is url-encoded.

argtypedesc
formHTMLFormmust be an HTMLForm element
optionsObjectoptional options object
optiontypedefaultdesc
hashbooleanfalseif true , the hash serializer will be used for serializer option
serializerfunctionurl-encodingoverride the default serializer (hash or url-encoding)
disabledbooleanfalseif true , disabled fields will also be serialized
emptybooleanfalseif true , empty fields will also be serialized

Serializers take 3 arguments: result , key , value and should return a newly updated result.

See the example serializers in the index.js source file.

only successful control form fields are serialized (with the exception of disabled fields if disabled option is set)

multiselect fields with more than one value will result in an array of values in the hash output mode using the default hash serializer

explicit array fields

Fields who’s name ends with [] are always serialized as an array field in hash output mode using the default hash serializer. The field name also gets the brackets removed from its name.

This does not affect url-encoding mode output in any way.

Adding numbers between brackets for the array notation above will result in a hash serialization with explicit ordering based on the index number regardless of element ordering.

Like the «explicit array fields» this does not affect url-encoding mode output in any way.

Similar to the indexed array notation, attribute names can be added by inserting a string value between brackets. The notation can be used to create deep objects and mixed with the array notation.

Like the «explicit array fields» this does not affect url-encoding mode output.

Читать еще:  Ошибка failed to initialize player
Ссылка на основную публикацию
Adblock
detector