jQuery反序列化表单 [英] jQuery deserialize form

查看:159
本文介绍了jQuery反序列化表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery序列化序列化我的表单元素,并想反序列化它们.不幸的是找不到任何有效的jQuery反序列化器,有什么建议吗?

I am using jQuery Serialize to serialize my form elements and would like to deserialize them back. Unfortunately can't find any working jQuery deserializer, any suggestions?

推荐答案

一半的jQuery序列化为 param( ),因此反序列化查询字符串的内容中有一半将成为参数.不幸的是,我无法找到一个很好的独立脱模工具.现在,我建议获取 jQuery BBQ库并使用它.如果您不需要其他东西,可以将其删除.我读过Ben Alman(牛仔)计划将deparam提取到自己的模块中的某个地方.

Half of jQuery Serialize is param(), so half of something that deserializes a query string is going to be a deparam. Unfortunately I haven't been able to find a good standalone deparam. For now I recommend getting the jQuery BBQ library and using that. If you don't need the other stuff you can remove them. I read somewhere that Ben Alman (cowboy) planned to extract deparam into its own module.

对于反序列化的其余部分,您只需要遍历deparam返回的对象,并针对该对象中的每个键和值对,基于键选择表单元素,并将表单元素值设置为值.

For the rest of deserializing, you'll just need to loop through the object that deparam returns and for each key and value pair in the object, select the form element based on the key, and set the form elements value to the value.

这篇关于jQuery反序列化表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆