Skip to content

Instantly share code, notes, and snippets.

@harmstyler
Created April 5, 2013 16:33
Show Gist options
  • Save harmstyler/5320683 to your computer and use it in GitHub Desktop.
Save harmstyler/5320683 to your computer and use it in GitHub Desktop.
Build a query string when given the params object
url = $.url();
params = url.param();
if (params.q != null) {
qs = buildQueryString(params);
}
buildQueryString = function(params) {
var param, qs;
qs = '';
for (param in params) {
if (qs === '') {
qs = '?';
} else {
qs = qs + '&';
}
qs = qs + param + '=' + encodeURIComponent(params[param]);
}
return qs;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment