Skip to content

Instantly share code, notes, and snippets.

@aabril
Created May 6, 2014 09:40
Show Gist options
  • Save aabril/e6b96379ab0eb151a179 to your computer and use it in GitHub Desktop.
Save aabril/e6b96379ab0eb151a179 to your computer and use it in GitHub Desktop.
Redirect with POST vars (on jQuery)
// http://stackoverflow.com/a/23347763
var redirect = 'http://www.website.com/page?id=23231';
$.redirectPost(redirect, {x: 'example', y: 'abc'});
// jquery extend function
$.extend(
{
redirectPost: function(location, args)
{
var form = '';
$.each( args, function( key, value ) {
form += '<input type="hidden" name="'+key+'" value="'+value+'">';
});
$('<form action="'+location+'" method="POST">'+form+'</form>').submit();
}
});
@geomorillo
Copy link

tx however not working for me

@merkuriy
Copy link

merkuriy commented Nov 4, 2015

Thx! Also on this subject has such a plugin (for those who are looking for a plugin) https://github.com/mgalante/jquery.redirect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment