JSLite - Form


If you have any questions, you are welcome to communicate in these places, and you are welcome to join the JSLite.io organization team for joint development!

Form

Some methods of form submission

submit

submit() method converts form data Submit to the web server. This is a method provided by the original ecosystem, and there have been no encapsulation changes*.

$("form")[0].submit() //此处直接原生态提交表单,日后封装,直接在JSLite对象上就可以提交。

serializeArray

Combines the values ​​used as submitted form elements into an array consisting of key-value pairs with name and value. Unavailable form elements, buttons, and unselected radio buttons/checkboxes will be skipped. The result does not contain data from file inputs.

$("form").serializeArray();
//=> [{"name":"golang","value":"456"},{"name":"name","value":""},{"name":"password","value":""},{"name":"sel","value":[]},{"name":"kaikai","value":""},{"name":"w","value":""},{"name":"w","value":""}]

serialize

Serialize the form element array or object.

$("form").serialize();
//=> golang=456&name=&password=&sel=&kaikai=&w=asd&w2=asdf