Skip to content

Instantly share code, notes, and snippets.

@Ryanb58
Created January 5, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryanb58/88e4c77f40358ff8042e to your computer and use it in GitHub Desktop.
Save Ryanb58/88e4c77f40358ff8042e to your computer and use it in GitHub Desktop.
JavaScript dictionary to query string or params script.
params_dict = {
'name':'New Rule',
'type': 'user',
};
// URL Builder from DICT.
params = "";
index = 0;
for (var key in params_dict) {
if (index == 0) {
params += "?" + key + "=" + params_dict[key]
}
else {
params += "&" + key + "=" + params_dict[key]
}
index++;
}
document.location.href = url + params;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment