JavaScript / jQuery中的$ .param()反函数 [英] The $.param( ) inverse function in JavaScript / jQuery

查看:136
本文介绍了JavaScript / jQuery中的$ .param()反函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下表格:

<form>
    <input name="foo" value="bar">
    <input name="hello" value="hello world">
</form>

我可以使用 $ .param(..)构造以序列化表单:

I can use the $.param( .. ) construct to serialize the form:

$.param( $('form input') )

=> foo=bar&hello=hello+world

如何用JavaScript反序列化上面的String并得到一个哈希回来?

How can I deserialize the above String with JavaScript and get a hash back?

例如,

$.magicFunction("foo=bar&hello=hello+world")

=> {'foo' : 'bar', 'hello' : 'hello world'}

参考:< a href =http://api.jquery.com/jQuery.param/#jQuery-param-obj =noreferrer> jQuery.param(obj)

推荐答案

你应该使用 jQuery BBQ deparam 功能。它经过了充分的测试和记录。

You should use jQuery BBQ's deparam function. It's well-tested and documented.

这篇关于JavaScript / jQuery中的$ .param()反函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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