Created
September 26, 2012 20:07
-
-
Save wolfiestyle/3790264 to your computer and use it in GitHub Desktop.
convert all links with class "post" to POST requests
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
$('a.post').click(function(ev) { | |
ev.preventDefault(); | |
var param = $(this).attr('href').replace(/^\?/, '').split('&').map(function(p) { return p.split('='); }); | |
$('<form method="POST" action="#">') | |
.append(param.map(function(e) { return '<input type="hidden" name="' + e[0] + '" value="' + e[1] + '" />'; })) | |
.appendTo('body').submit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment