【问题标题】:Serializing form data with field names that have dots in them使用带有点的字段名称序列化表单数据
【发布时间】:2011-02-14 01:28:30
【问题描述】:

jQuery 中的序列化函数是否将点 ('.') 替换为下划线?

例如,我有一个表单字段,例如:

<input id="Project.name" name="Project.name" type="text">

当表单发布后,我将表单数据序列化并将其发送到另一个 PHP 文件进行保存。点似乎转换为下划线。这是正常行为吗?

【问题讨论】:

    标签: php jquery forms


    【解决方案1】:

    jQuery 不这样做,the easiest way to see this is to test, you can see it here。自从为我在 PHP 中做任何事情以来已经很长时间了,但看起来服务器端正在发生一些事情。

    这是一个简单的测试:

    <form>
      <input id="Project.name" name="Project.name" type="text" value="test" />
    </form>
    

    这个 jQuery:

    alert($("form").serialize()); // "Project.name=test"
    

    查看实际发布内容的另一种简单方法是Firebug,或任何其他选择的流量检查工具。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 2016-08-24
    • 1970-01-01
    • 2017-09-21
    • 2023-03-03
    • 2016-09-06
    • 2021-10-27
    相关资源
    最近更新 更多