jquery序列化问题

标签 jquery serialization

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

我得到了这个返回:

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

并且需要清理数据库提交的 URL 内容 - (“+”符号 nad %2C(逗号)。

是否有一种简单的方法可以反转标准 URL 编码表示法?

最佳答案

Is there something else I can use on a form to get all the elements and their values that won't put them into URL notation?

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

示例:

var a, index, entry;
a = $("#theForm").serializeArray();
for (index = 0; index < a.length; ++index) {
  entry = a[index];
  display("a[" + index + "]: " + entry.name + "=" + entry.value);
}

Live copy

Is there a simple way to reverse standard URL-encoded notation?

是的。各个编码值可以使用 decodeURIComponent 进行解码;完整的字段字符串可以使用 decodeURI 进行解码.

关于jquery序列化问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5596573/

相关文章:

serialization - RIA DomainService 不使用 DataContracts 生成客户端代码

java - XmlElement 注解可以有多种类型吗?

jquery - 是否可以使用 jquery 和 mysql 在数据库表中插入一条新记录?

javascript - 获取对象内部字符串中的最高数字

javascript - 从表 TR id 和 TD id 获取值

.net - JSON序列化时如何使用JavaScriptSerializer设置格式?

javascript - 如何创建一个可以作用于 future 元素的函数?

javascript - 如何在 JQuery 中访问 Angular 6 变量

java - 在java中覆盖类签名

java - 如何在 UDAF 中使用第三方不可序列化对象?