Created
September 18, 2015 09:55
-
-
Save egulhan/11d2edc15a0fe8a4f4eb to your computer and use it in GitHub Desktop.
How-to create form on the fly and send via POST method by using JQuery
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(){ | |
| // create form on the fly | |
| var $new_form = $('<form>', { | |
| 'action': '<?php echo BASE_URL; ?>/operation/reset_member_password', | |
| 'method': 'POST', | |
| 'target': '_top' | |
| }).append(jQuery('<input>', { | |
| 'name': 'member_id', | |
| 'value': member_id, | |
| 'type': 'hidden' | |
| })); | |
| // send form | |
| $new_form.submit(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it seems that you have to append form to the body for submit to work, so last instruction should become:
$new_form.appendTo('body').submit();