2k20 update: use Josh's solution with URLSearchParams.toString().
Old answer:
Without jQuery
var params = {
parameter1: 'value_1',
parameter2: 'value 2',
parameter3: 'value&3'
};
var esc = encodeURIComponent;
var query = Object.keys(params)
.map(k => esc(k) + '=' + esc(params[k]))
.join('&');
For browsers that don't support arrow function syntax which requires ES5, change the .map...
line to
.map(function(k) {return esc(k) + '=' + esc(params[k]);})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…