Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery序列化问题_Jquery_Serialization - Fatal编程技术网

jquery序列化问题

jquery序列化问题,jquery,serialization,Jquery,Serialization,我是否可以在表单上使用其他东西来获取所有元素及其值,而不将它们放入URL符号中?或者有没有一种快速的方法来清理返回的字符串 我要退回这个: filePath=afile.doc&fileTitle=A+File&fileDescription=This+should+be+first+in+an+asc+sort%2C+last+in+A+desc 并且需要为数据库提交清理URL内容—“+”符号和%2C(逗号) 有没有一种简单的方法可以反转标准的URL编码符号 我是否可以在表单上使用其他东西来获

我是否可以在表单上使用其他东西来获取所有元素及其值,而不将它们放入URL符号中?或者有没有一种快速的方法来清理返回的字符串

我要退回这个:

filePath=afile.doc&fileTitle=A+File&fileDescription=This+should+be+first+in+an+asc+sort%2C+last+in+A+desc

并且需要为数据库提交清理URL内容—“+”符号和%2C(逗号)

有没有一种简单的方法可以反转标准的URL编码符号

我是否可以在表单上使用其他东西来获取所有元素及其值,而不将它们放入URL符号中

是的,您可以使用jQuery,它将“…将一组表单元素编码为名称和值的数组。”这将是最好的,因为您首先避免进行编码(我认为您希望使用未编码的值版本)

例如:

var a, index, entry;
a = $("#theForm").serializeArray();
for (index = 0; index < a.length; ++index) {
  entry = a[index];
  display("a[" + index + "]: " + entry.name + "=" + entry.value);
}
var a、索引、分录;
a=$(“#theForm”).serializeArray();
对于(索引=0;索引

有没有一种简单的方法可以反转标准的URL编码符号


是的。可以使用对单个编码值进行解码;可以使用对整个字段字符串进行解码。

我认为可以使用服务器端语言对URL进行解码,例如php中的字符串urldecode(string$str);

如果使用post而不是查询,则可以将元素命名为数组

<input type="hidden" name="block[369][filepath]" value="somepath"/>
<input type="hidden" name="block[369][title]" value="somefile.gif"/>
<input type="hidden" name="block[369][description]" value="imagefile"/>

我在这里假设allot,但这就是我将东西放入数组进行php解析的方式,所以我不必依赖jQuery进行序列化


只是一个想法

对您使用的环境很重要?PHP、ASP.net等。您希望将此URL编码的数据反转为什么?如果您控制服务器端代码,最好将此数据作为JSON字符串返回,它可以很容易地转换为JS中的对象。@Hans只是一个简单的字符串。这适用于用户编辑数据时(以表格格式显示)。他们单击编辑按钮,数据以表格形式显示。单击提交按钮时,我需要首先进行验证,因此我使用序列化将所有数据转换为字符串。但我不需要对其进行url编码。这有帮助吗?谢谢TJ,这正是我需要的。@PruitIgoe:很好,很高兴这有帮助。