JSFiddle - React, Tailwind, and code Playground
HTML
<a post="true" phref="pagetopost.php" pdata='{"name1": "value1","name2": "value2"}'>This is a post link</a>
<br/>
<a href="http://www.google.com">This is normal link</a>
CSS
a[post=true] {
cursor: pointer;
text-decoration: underline;
color: #0000FF;
}
JavaScript
function makePostRequest(url, data) {
var jForm = $('<form></form>');
jForm.attr('action', url);
jForm.attr('method', 'post');
for (name in data) {
var jInput = $("<input>");
jInput.attr('name', name);
jInput.attr('value', data[name]);
jForm.append(jInput);
}
jForm.submit();
}
$(function(){
$("a[post=true]").each(function () {
$(this).on('click', function () {
makePostRequest(
$(this).attr('phref'),
JSON.parse($(this).attr('pdata'))
);
});
});
});