.serialize()Возвращает: String

Описание: Возвращает строку, с именами и значениями выбранных элементов формы. Эта строка будет иметь формат параметров url-запроса.

  • Добавлен в версии: 1.0.serialize()

    • This method does not accept any arguments.

The .serialize() method creates a text string in standard URL-encoded notation. It can act on a jQuery object that has selected individual form controls, such as <input>, <textarea>, and <select>: $( "input, textarea, select" ).serialize();

It is typically easier, however, to select the <form> itself for serialization:

$( "form" ).on( "submit", function( event ) {
console.log( $( this ).serialize() );

In this case, jQuery serializes the successful controls within the form. Only form elements are examined for inputs they contain, in all other cases the input elements to be serialized should be part of the set passed to the .serialize() method. Selecting both the form and its children in a set will cause duplicates in the serialized string.

Note: Only "successful controls" are serialized to the string. No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a name attribute. Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked. Data from file select elements is not serialized.

Примеры использования