Answer the question
In order to leave comments, you need to log in
How to send a POST request to a link?
I need that when I click on a link, I send a post request to a specific address. But not with ajax. For the page to reload
Answer the question
In order to leave comments, you need to log in
Instead of a link, you make a form, a POST method, and a submit button.
Or, as Dmitry said (we make a form and insert a button).
Or with jQuery.
<form action="/" class="test__form" method="POST">
<a href="#" class="submitlink">click me</a>
</form>
let form = $('.test__form'),
submitLink = form.children('.submitlink');
submitLink.click(function(e) {
e.preventDefault();
form.submit();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question