Odkaz odeslat jako POST
Odeslat odkaz jako POST je velmi jednoduché
vše co je v odkazu jako GET se převede na POST. Stačí kousek kódu v podobě jquery.
zdroj: http://stackoverflow.com/questions/2304320/jquery-onclick-pass-post-variables-and-reload-page
vše co je v odkazu jako GET se převede na POST. Stačí kousek kódu v podobě jquery.
<a class="postlink" href="http://www.fedia.cz/testovani.php?name=test">Odkaz</a>
<script type="text/javascript">
$('.postlink').click(function() {
var form= document.createElement('form');
form.method= 'post';
form.action= this.protocol+'//'+this.hostname+this.pathname;
$.each(this.search.slice(1).split(/[&;]/g), function() {
var ix= this.indexOf('=');
if (ix===-1) return;
var input= document.createElement('input');
input.type= 'hidden';
input.name= decodeURIComponent(this.slice(0, ix));
input.value= decodeURIComponent(this.slice(ix+1));
form.appendChild(input);
});
document.body.appendChild(form);
form.submit();
return false;
});
</script>
$('.postlink').click(function() {
var form= document.createElement('form');
form.method= 'post';
form.action= this.protocol+'//'+this.hostname+this.pathname;
$.each(this.search.slice(1).split(/[&;]/g), function() {
var ix= this.indexOf('=');
if (ix===-1) return;
var input= document.createElement('input');
input.type= 'hidden';
input.name= decodeURIComponent(this.slice(0, ix));
input.value= decodeURIComponent(this.slice(ix+1));
form.appendChild(input);
});
document.body.appendChild(form);
form.submit();
return false;
});
</script>
zdroj: http://stackoverflow.com/questions/2304320/jquery-onclick-pass-post-variables-and-reload-page

Komentáře
Okomentovat
Napište komentář. Budu rád.