- equivalent to jQuery.param
- no jQuery necessary
- no dependencies
- legacy IE support
When making a GET/POST request in Web Workers etc., which cannot use jQuery. Especially when sending Array as a parameter.
Node.js:
$ npm install jquery-param --save
Bower:
$ bower install jquery-param
browser:
<script src="./src/jquery-param.min.js"></script>
Node.js:
var param = require('jquery-param');
var obj = { key1: 'value1', key2: [10, 20, 30] };
var str = param(obj);
// => "key1=value1&key2[]=10&key2[]=20&key2[]=30"
browser:
var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
var str = window.param(obj);
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
Chrome, Firefox, Safari, Opera, and Internet Explorer 6+.
MIT