solvit.io

Transform a JavaScript array or object into a URL query string using jQuery

Solution
var parameters = { 'property1': 'value1', 'property2': 'value2' };
var queryString = $.param(parameters);
Example
var parameters = { 'user': 'John Smith', 'max': 10, 'sort': 'desc' };
var queryString = $.param(parameters);
// queryString = 'user=John%20Smith&max=10&sort=desc'
Find more solutions about: , , ,