Skip to content

Instantly share code, notes, and snippets.

@sankitch
Created July 19, 2013 14:28
Show Gist options
  • Save sankitch/6039494 to your computer and use it in GitHub Desktop.
Save sankitch/6039494 to your computer and use it in GitHub Desktop.
function buildUrl(url, parameters) {
var qs = "";
for(var key in parameters) {
var value = parameters[key];
qs += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&";
}
if (qs.length > 0){
qs = qs.substring(0, qs.length-1); //chop off last "&"
url = url + "?" + qs;
}
return url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment