Created
January 5, 2016 16:36
-
-
Save Ryanb58/88e4c77f40358ff8042e to your computer and use it in GitHub Desktop.
JavaScript dictionary to query string or params script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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