As of HTML5, in some browsers , I can use the download attribute on anchor directives:
<a href="my-site.com/read_me.txt" download>
I can even parameterize it:
<a href="my-site.com/secret.php?user=me&password=letmein" download>
But maybe I want some privacy.
is there any conceivable way to use POST
, rather than GET
?
If not, I will obfuscate the parameters. I am 99% sure that it can't be done, and want someone to add the last 1% to that.
No you can't force an anchor element to do a POST request; It's always GET.
for a POST request, you must submit a form:
common javascript style:
<a onclick="document.getElementById('form_id').submit();">click here</a>
using jquery:
$(function() {
$("#anchor_id").on("click",function(e) {
e.preventDefault();
$.post(this.href,function(data) {
// callback function
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With