Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function buildQuery(params) {
- if (!isPlainObject(params)) {
- return null;
- }
- function build(data, name) {
- var result = [];
- for (var key in data) {
- if (data.hasOwnProperty(key)) {
- var value = data[key];
- key = encodeURIComponent(key);
- if (name) {
- key = name + '[' + key + ']';
- }
- if (isPlainObject(value) || isArray(value)) {
- result.push(arguments.callee(value, key));
- } else {
- result.push(key + '=' + encodeURIComponent(value));
- }
- }
- }
- return result.join('&');
- }
- return build(params);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement