Created
November 29, 2013 01:50
-
-
Save Havvy/7700523 to your computer and use it in GitHub Desktop.
Do a POST request, redirecting the current page to the result.
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
| function post(url, values) { | |
| function add_input(name, value) { | |
| var input = document.createElement("input"); | |
| input.name = name; | |
| input.value = value; | |
| form.appendChild(input); | |
| } | |
| var form = document.createElement("form"); | |
| Object.keys(values).forEach(function (name) { | |
| value = values[name]; | |
| add_input(name, value); | |
| }); | |
| form.submit(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment