jQuery API 返回首页目录 | jQuery API 中英文对照版
formSerialize(true)

formSerialize(true)

Serializes form data into a 'submittable' string. This method will return a string in the format: name1=value1&name2=value2 The semantic argument can be used to force form serialization in semantic order. If your form must be submitted with name/value pairs in semantic order then pass true for this arg, otherwise pass false (or nothing) to avoid the overhead for this logic (which can be significant for very large forms).

返回值

String

参数

  • true (semantic): if serialization must maintain strict semantic ordering of elements (slower)

示例

说明:

Collect all the data from a form into a single string

jQuery 代码:
var data = $("#myForm").formSerialize(); $.ajax('POST', "myscript.cgi", data);
相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog