Created
February 18, 2014 22:56
-
-
Save kmck/9082211 to your computer and use it in GitHub Desktop.
This file contains 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
// Assumes jQuery | |
function form_submit(attributes, action, method) { | |
var $form = $('<form>').attr({ | |
method: method ||'post', | |
action: action || window.location.pathname | |
}); | |
$.each(attributes, function(name, value) { | |
$(value.indexOf('\n') < 0 ? '<input>' : '<textarea>').attr('name', name).val(value).appendTo($form); | |
}); | |
$form.appendTo('body').submit().remove(); | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment