PHP's http_build_query function Generates URL-encoded query string I need the exact same functionality in javascript.
Function example:
$data = array(
'foo' => 'bar',
'baz' => 'boom',
'cow' => 'milk',
'php' => 'hypertext processor'
);
echo http_build_query($data) . "n";
Output:
foo=bar&baz=boom&cow=milk&php=hypertext+processor
I want the same output in javascript. I tried encodeURIComponent but it's solving adifferent purpose.