How to implement something like PHP's http_build_query and the reverse in javascript?

后端 未结 3 1014
离开以前
离开以前 2021-02-15 11:24
\'bar\',
              \'baz\'=>\'boom\',
              \'cow\'=>\'milk\',
              \'php\'=>\'hypertext processor\');

         


        
3条回答
  •  离开以前
    2021-02-15 12:01

    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.

提交回复
热议问题