I don’t want to use GET method for some destructive links (like deleting an item, remove something…) so I use POST or DELETE actions on my links, with a Javascript AJAX request like this:
<a class="js-link" data-method="DELETE" data-confirmation="Are you sure?" data-href="xxx">
I don't use href because the URL is not available with a GET method (error 405).
My questions are:
- What are the best-practices for these kind of links?
- Is this valid HTML?
- What about users without JS, old browsers?
Thanks :)
As mentioned in the comments, the appropriate solution here is to use a
<button>or similar. Since these are not hypertext links that you can follow, which can be followed by e.g. search engine crawlers, they should not be represented using the<a>hypertext anchor element.Note that according to the standard:
so your usage of
href-less<a>does not match the standard's definition.