Skip to content

Instantly share code, notes, and snippets.

@Havvy
Created November 29, 2013 01:50
Show Gist options
  • Select an option

  • Save Havvy/7700523 to your computer and use it in GitHub Desktop.

Select an option

Save Havvy/7700523 to your computer and use it in GitHub Desktop.
Do a POST request, redirecting the current page to the result.
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