wh2017 / jquery-param

equivalent function to jQuery.param

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jquery-param

Circle CI

Features

  • Equivalent to jQuery.param (based on jQuery 3.x)
  • No dependencies
  • Universal (Isomorphic)
  • ES5

Installation

Node.js:

$ npm install jquery-param --save

Bower (DEPRECATED):

$ bower install jquery-param

the browser:

<script src="jquery-param.min.js"></script>

Usage

Node.js:

const param = require('jquery-param');

let obj = { key1: 'value1', key2: [10, 20, 30] };
let str = param(obj);
// => "key1=value1&key2[]=10&key2[]=20&key2[]=30"

AMD:

require(['jquery-param'], function (param) {
    var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
    var str = param(obj);
    // => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
});

directly:

var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
var str = window.param(obj);    // global object
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"

Browser Support

Chrome, Firefox, Safari, Edge, and IE9+.

License

MIT

About

equivalent function to jQuery.param

License:MIT License


Languages

Language:JavaScript 97.1%Language:HTML 2.9%