简体   繁体   English

尝试使用jQuery序列化()一组输入字段

[英]Trying to serialize() a group of input fields with jQuery

I am trying to serialize() a group of input field data and am not getting anything in my logs. 我正在尝试对一组输入字段数据进行serialize() ,但日志中没有任何内容。 Can someone point me in the right direction? 有人可以指出我正确的方向吗? I have read the jQuery documentation on .seralize() and it "looks" like I am doing it right. 我已经阅读了.seralize()上的jQuery文档,它“看起来”就像我做对了一样。 Here is a fiddle roughly of what I am working with: http://jsfiddle.net/GaY96/ 以下是我正在使用的工具的小提琴: http : //jsfiddle.net/GaY96/

The .serialize() uses input element's name, to serialize it. .serialize()使用input元素的名称进行序列化。 In your case it is missing. 就您而言,它丢失了。

<input name="unitname" type="text" value="test" placeholder="Unit Name" />

Also calling it in an non form element(other than form and input elements) does not seems to be working . 同样在非表单元素(除了表单和输入元素) 调用它似乎也不起作用 So try 所以尝试

var datastring = $(".editunitinfo :input").serialize();

Demo: Fiddle 演示: 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM