Describes several common forms processing functions of jquery: 1. serialize the Form Content element as a string, which is often used for ajax submission. $ (& Quot; form & quot;). serialize () & amp; nbsp; 2. & amp; nbsp; serializeArray () sequence
Describes several common forms processing functions of jquery:
1. serialize the Form Content element as a string, which is often used for ajax submission.
$ ("Form"). serialize ()
2. serializeArray () serializes table data and returns json structure data. Note that it returns a json object instead of a json string. If you use it to obtain form data for submission, the server may need to process it like this in php:
// JS var data = $ ("# form: input "). serializeArray (); data = JSON. stringify (data); post_var = {'action': 'process', 'data': data}; $. ajax ({..... etc // PHP $ data = json_decode (stripslashes ($ _ POST ['data']), true); print_r ($ data ); // this will print out the post data as an associative array
3. $. param () is used to serialize an array or object according to key/value.
$. Param ({a: [2, 3, 4]}) // "a = 2 & a = 3 & a = 4"