且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在javascript中实现类似PHP的http_build_query和反向的东西?

更新时间:2023-02-25 15:09:03

如果你正在使用jQuery,那么你可以使用 jQuery.param ()功能:

If you're using jQuery, then you can use the jQuery.param() function:

var obj = { "foo":"bar", "baz":"boom", "php":"hypertext processor" };
var str = jQuery.param(obj);
alert(str); // should be "foo=bar&baz=boom&php=hypertext+processor"

它可以序列化一些复杂的数组。

It can serialise some complex arrays too.