Skip to content

Instantly share code, notes, and snippets.

@wolfiestyle
Created September 26, 2012 20:07
Show Gist options
  • Save wolfiestyle/3790264 to your computer and use it in GitHub Desktop.
Save wolfiestyle/3790264 to your computer and use it in GitHub Desktop.
convert all links with class "post" to POST requests
$('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