Created
May 6, 2014 09:40
-
-
Save aabril/e6b96379ab0eb151a179 to your computer and use it in GitHub Desktop.
Redirect with POST vars (on jQuery)
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
// 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(); | |
} | |
}); |
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
tx however not working for me