【问题标题】:Collect all the items in a form in jQuery在jQuery中收集表单中的所有项目
【发布时间】:2009-06-16 15:22:51
【问题描述】:

如何收集jQuery中的所有复选框和下拉列表项进行保存?

【问题讨论】:

标签: jquery forms collections


【解决方案1】:

或者,对于最新版本的 jquery,您可以使用:

http://docs.jquery.com/Ajax/serialize - 转为 URL 编码字符串 person.name=john&person.age=20

http://docs.jquery.com/Ajax/serializeArray - 转 JSON

【讨论】:

    【解决方案2】:

    一种方法是使用 jQuery Form 插件,像这样:

    $('#myFormId').formSerialize(); 
    

    来自formSerialize API documentation

    Serializes the form into a query string. This method will return a string in the format: name1=value1&name2=value2
    

    【讨论】:

    • 如何将.formSerialize()结果传递给ajaxSubmit()
    【解决方案3】:

    $('#myFormId').formSerialize();是一个插件,也许没有必要。 核心函数serialize()更好。

    http://docs.jquery.com/Ajax/serialize

    【讨论】:

    • 我的视图状态在我做 .serialize 时也是可见的
    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2020-11-16
    • 1970-01-01
    • 2014-01-11
    • 2019-08-05
    • 2013-03-12
    • 1970-01-01
    相关资源
    最近更新 更多